realtimenetprots/sipfw/SIP/Transaction/src/NormalClientTaStates.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          : NormalClientTaStates.cpp
       
    15 // Part of       : Transaction
       
    16 // Version       : SIP/5.0
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "SipAssert.h"
       
    22 #include "sipresponse.h"
       
    23 #include "SIPMessageUtility.h"
       
    24 
       
    25 #include "NormalClientTa.h"
       
    26 #include "NormalClientTaStates.h"
       
    27 #include "ClearProxy.h"
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CNormalClientTa_Trying::CNormalClientTa_Trying
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CNormalClientTa_Trying::CNormalClientTa_Trying()
       
    34 	{
       
    35 	}
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CNormalClientTa_Trying::~CNormalClientTa_Trying
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CNormalClientTa_Trying::~CNormalClientTa_Trying()
       
    42 	{
       
    43 	}
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CNormalClientTa_Trying::GetState
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void CNormalClientTa_Trying::GetState(CSIPInternalStates::TState& aState) const
       
    50     {
       
    51     aState = CSIPInternalStates::ETransactionTrying;
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CNormalClientTa_Trying::SetNeighbourStates
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 void CNormalClientTa_Trying::SetNeighbourStates(CTransactionState& aProceeding,
       
    59 												CTransactionState& aCompleted)
       
    60 	{
       
    61 	iProceeding = &aProceeding;
       
    62 	iCompleted = &aCompleted;
       
    63 	}
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CNormalClientTa_Trying::SendRequestL
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void CNormalClientTa_Trying::SendRequestL(CTransaction& aTransaction,
       
    70 									  	  CSIPRequest& aReq,
       
    71 									  	  const TInetAddr& aAddress,
       
    72 									  	  RStringF aProtocol,
       
    73 									  	  TBool aForceUDP,
       
    74 									  	  const TSIPTransportParams& aParams,
       
    75 									  	  CUri8* aOutboundProxy) const
       
    76 	{
       
    77     __SIP_ASSERT_LEAVE(CSIPMessageUtility::CheckTransport(aProtocol),
       
    78                        KErrArgument);
       
    79 
       
    80 	CNormalClientTransaction& ta = CNormalClientTransaction::Ptr(aTransaction);
       
    81 
       
    82 	TClearProxy clearProxy(ta);
       
    83     CleanupStack::PushL(clearProxy.CleanupItem());
       
    84 
       
    85 	ta.StoreRequest(aReq,
       
    86 					aAddress,
       
    87 					aParams,
       
    88 					aProtocol,
       
    89 					aForceUDP,
       
    90 					aOutboundProxy);
       
    91 	ta.SendToTransmitterL();	
       
    92 
       
    93 	CleanupStack::Pop(); //cleanupItem
       
    94 	}
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CNormalClientTa_Trying::SendCompleteL
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CNormalClientTa_Trying::SendCompleteL(CTransaction& aTransaction) const
       
   101 	{
       
   102 	CNormalClientTransaction& ta = CNormalClientTransaction::Ptr(aTransaction);
       
   103 	ta.CheckForTransportChange();	
       
   104 	ta.StartTimerFUnlessExistsL();
       
   105 
       
   106 	if (aTransaction.IsUnreliableTransportUsed())
       
   107 		{
       
   108 		ta.StartTimerEL();
       
   109 		}
       
   110 	}
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CNormalClientTa_Trying::SendFailedL
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 void CNormalClientTa_Trying::SendFailedL(CTransaction& aTransaction,
       
   117 										 TInt aError) const
       
   118 	{
       
   119 	aTransaction.TerminatedL(aError);
       
   120 	}
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CNormalClientTa_Trying::ReceiveL
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 void CNormalClientTa_Trying::ReceiveL(CTransaction& aTransaction,
       
   127 	                                  CSIPResponse* aResponse) const
       
   128 	{
       
   129     __SIP_ASSERT_LEAVE(aResponse, KErrArgument);
       
   130 
       
   131     CNormalClientTransaction::Ptr(aTransaction).ReceiveResponseL(aResponse,
       
   132 				                                                 *this,
       
   133 				                                                 *iProceeding,
       
   134 				                                                 *iCompleted);
       
   135 	}
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CNormalClientTa_Trying::TimerExpiredL
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CNormalClientTa_Trying::TimerExpiredL(CTransaction& aTransaction,
       
   142 										   TTimerId aTimerId,
       
   143 										   TAny* aTimerParam) const
       
   144 	{    
       
   145     __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument);	
       
   146 
       
   147 	HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam);
       
   148 	}
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CNormalClientTa_Proceeding::CNormalClientTa_Proceeding
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 CNormalClientTa_Proceeding::CNormalClientTa_Proceeding()
       
   155 	{
       
   156 	}
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CNormalClientTa_Proceeding::~CNormalClientTa_Proceeding
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 CNormalClientTa_Proceeding::~CNormalClientTa_Proceeding()
       
   163 	{
       
   164 	}
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CNormalClientTa_Proceeding::GetState
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void
       
   171 CNormalClientTa_Proceeding::GetState(CSIPInternalStates::TState& aState) const
       
   172     {
       
   173     aState = CSIPInternalStates::ETransactionProceeding;
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CNormalClientTa_Proceeding::SetNeighbourStates
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CNormalClientTa_Proceeding::SetNeighbourStates(CTransactionState& aCompleted)
       
   181 	{
       
   182 	iCompleted = &aCompleted;
       
   183 	}
       
   184 
       
   185 // -----------------------------------------------------------------------------
       
   186 // CNormalClientTa_Proceeding::SendCompleteL
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void CNormalClientTa_Proceeding::SendCompleteL(CTransaction& aTransaction) const
       
   190 	{
       
   191 	CNormalClientTransaction& ta = CNormalClientTransaction::Ptr(aTransaction);
       
   192 	ta.CheckForTransportChange();
       
   193 
       
   194 	if (aTransaction.IsUnreliableTransportUsed())
       
   195 		{
       
   196 		//In proceeding state, timer E is set with value T2
       
   197 		ta.IncreaseTimerEtoT2();
       
   198 		ta.StartTimerEL();
       
   199 		}
       
   200 	}
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CNormalClientTa_Proceeding::SendFailedL
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CNormalClientTa_Proceeding::SendFailedL(CTransaction& aTransaction,
       
   207 											 TInt aError) const
       
   208 	{
       
   209 	aTransaction.TerminatedL(aError);
       
   210 	}
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CNormalClientTa_Proceeding::ReceiveL
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 void CNormalClientTa_Proceeding::ReceiveL(CTransaction& aTransaction,
       
   217 	                                      CSIPResponse* aResponse) const
       
   218 	{
       
   219     __SIP_ASSERT_LEAVE(aResponse, KErrArgument);
       
   220 
       
   221     CNormalClientTransaction::Ptr(aTransaction).ReceiveResponseL(aResponse,
       
   222 				                                                 *this,
       
   223 				                                                 *this,
       
   224 				                                                 *iCompleted);
       
   225 	}
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CNormalClientTa_Proceeding::TimerExpiredL
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 void CNormalClientTa_Proceeding::TimerExpiredL(CTransaction& aTransaction,
       
   232 											   TTimerId aTimerId,
       
   233 											   TAny* aTimerParam) const
       
   234 	{    
       
   235     __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument);
       
   236 	
       
   237 	HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam);
       
   238 	}
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // CNormalClientTa_Completed::CNormalClientTa_Completed
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 CNormalClientTa_Completed::CNormalClientTa_Completed()
       
   245 	{
       
   246 	}
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CNormalClientTa_Completed::~CNormalClientTa_Completed
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 CNormalClientTa_Completed::~CNormalClientTa_Completed()
       
   253 	{
       
   254 	}
       
   255 
       
   256 // -----------------------------------------------------------------------------
       
   257 // CNormalClientTa_Completed::GetState
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 void
       
   261 CNormalClientTa_Completed::GetState(CSIPInternalStates::TState& aState) const
       
   262     {
       
   263     aState = CSIPInternalStates::ETransactionCompleted;
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CNormalClientTa_Completed::CanContinueWithoutOutgoingMsg
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 TBool CNormalClientTa_Completed::CanContinueWithoutOutgoingMsg() const
       
   271 	{	
       
   272 	return ETrue;
       
   273 	}
       
   274 
       
   275 // -----------------------------------------------------------------------------
       
   276 // CNormalClientTa_Completed::SendCompleteL
       
   277 // Occurs if Completed state was entered before receiving sending status event.
       
   278 // No action.
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 void
       
   282 CNormalClientTa_Completed::SendCompleteL(CTransaction& /*aTransaction*/) const
       
   283 	{
       
   284 	}
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CNormalClientTa_Completed::SendFailedL
       
   288 // -----------------------------------------------------------------------------
       
   289 //
       
   290 void CNormalClientTa_Completed::SendFailedL(CTransaction& aTransaction,
       
   291 											TInt aError) const
       
   292 	{
       
   293 	aTransaction.TerminatedL(aError);
       
   294 	}
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CNormalClientTa_Completed::ReceiveL
       
   298 // Final response already received. Ignore further responses.
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 void CNormalClientTa_Completed::ReceiveL(CTransaction& /*aTransaction*/,
       
   302 	                                     CSIPResponse* aResponse) const
       
   303 	{
       
   304     __SIP_ASSERT_LEAVE(aResponse, KErrArgument);
       
   305 
       
   306     delete aResponse;
       
   307 	}
       
   308 
       
   309 // -----------------------------------------------------------------------------
       
   310 // CNormalClientTa_Completed::TimerExpiredL
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 void CNormalClientTa_Completed::TimerExpiredL(CTransaction& aTransaction,
       
   314 											  TTimerId aTimerId,
       
   315 											  TAny* aTimerParam) const
       
   316 	{    
       
   317     __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument);
       
   318 
       
   319 	HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam);
       
   320 	}