realtimenetprots/sipfw/SIP/sipapi/src/sipdialogconfirmed.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2003-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          : sipdialogconfirmed.cpp
       
    15 // Part of       : SIPAPI
       
    16 // Version       : SIP/4.0 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #include "sip.h"
       
    22 #include "SipAssert.h"
       
    23 #include "sipdialogconfirmed.h"
       
    24 #include "SipDialogImplementation.h"
       
    25 #include "sipclienttransaction.h"
       
    26 #include "sipservertransaction.h"
       
    27 #include "sipresponseelements.h"
       
    28 #include "siprefresh.h"
       
    29 #include "sipinvitedialogassoc.h"
       
    30 #include "sipsubscribedialogassoc.h"
       
    31 #include "sipnotifydialogassoc.h"
       
    32 #include "sipreferdialogassoc.h"
       
    33 #include "sipconnectioncallback.h"
       
    34 #include "sipstrings.h"
       
    35 #include "sipstrconsts.h"
       
    36 
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CDialogConfirmed::NewL
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CDialogConfirmed* CDialogConfirmed::NewL()
       
    43     {
       
    44     return new (ELeave) CDialogConfirmed();
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CDialogConfirmed::CDialogConfirmed
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CDialogConfirmed::CDialogConfirmed()
       
    52 	{
       
    53 	}
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CDialogConfirmed::~CDialogConfirmed
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CDialogConfirmed::~CDialogConfirmed()
       
    60 	{
       
    61 	}
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CDialogConfirmed::State
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 CSIPDialog::TState CDialogConfirmed::State() const
       
    68     {
       
    69     return CSIPDialog::EConfirmed;
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CDialogConfirmed::SetNeighbourStates
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CDialogConfirmed::SetNeighbourStates(CDialogState& aTerminated)
       
    77     {    
       
    78     iTerminated = &aTerminated;
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CDialogConfirmed::SendInviteL
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CSIPClientTransaction*
       
    86 CDialogConfirmed::SendInviteL(const CSIPDialogImplementation& /*aDialog*/,
       
    87                               CSIPInviteDialogAssoc& aAssoc,
       
    88                               CSIPMessageElements* aElements) const
       
    89     {
       
    90     return aAssoc.DoSendRequestWithinDialogL(
       
    91     							SIPStrings::StringF(SipStrConsts::EInvite),
       
    92 								aElements);
       
    93 	}
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CDialogConfirmed::SendSubscribeL
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 CSIPClientTransaction* 
       
   100 CDialogConfirmed::SendSubscribeL(const CSIPDialogImplementation& /*aDialog*/,
       
   101                                  CSIPSubscribeDialogAssoc& aAssoc,
       
   102                                  CSIPMessageElements* aElements,
       
   103                                  CSIPRefresh* aRefresh) const
       
   104     {
       
   105     return aAssoc.DoSendSubscribeL(aElements, aRefresh, ETrue);
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CDialogConfirmed::UpdateL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 CSIPClientTransaction*
       
   113 CDialogConfirmed::UpdateL(const CSIPDialogImplementation& /*aDialog*/,
       
   114                 	  	  CSIPSubscribeDialogAssoc& aAssoc,
       
   115                 	  	  CSIPMessageElements* aElements) const
       
   116 	{
       
   117 	return aAssoc.DoSendSubscribeL(aElements, NULL, ETrue);
       
   118 	}
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CDialogConfirmed::SendNonTargetRefreshRequestL
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 CSIPClientTransaction* CDialogConfirmed::SendNonTargetRefreshRequestL(
       
   125 									const CSIPDialogImplementation& aDialog,
       
   126                                     CSIPDialogAssocImplementation& aAssoc,
       
   127                                     RStringF aMethod,
       
   128                                     CSIPMessageElements* aElements) const
       
   129     {
       
   130     return aDialog.SendRequestInDialogL(aAssoc, aMethod, aElements);
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CDialogConfirmed::IncomingResponseL
       
   135 // "this" is passed instead of the real early-state, since early state is never
       
   136 // entered from confirmed state.
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 TBool
       
   140 CDialogConfirmed::IncomingResponseL(CSIPDialogImplementation& aDialog,
       
   141                                     CSIPResponseElements* aElements,
       
   142 		                            TUint32 aRequestId,
       
   143                                     TUint32 aDialogId,
       
   144                                     CConnectionCallback& aCallback) const
       
   145     {
       
   146     return IncomingResponseWithinDialogL(aDialog,
       
   147                                          aElements,
       
   148 		                                 aRequestId,
       
   149                                          aDialogId,
       
   150                                          aCallback,
       
   151                                          *this,
       
   152                                          *this,
       
   153                                          *iTerminated);
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // CDialogConfirmed::IncomingResponseL
       
   158 // "this" is passed instead of the real early-state, since early state is never
       
   159 // entered from confirmed state.
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TBool CDialogConfirmed::IncomingResponseL(CSIPDialogImplementation& aDialog,
       
   163                                           CSIPResponseElements* aElements,
       
   164 		                                  TUint32 aRequestId,
       
   165                                           TUint32 aRefreshId,
       
   166                                           TUint32 /*aDialogId*/,
       
   167                                           CConnectionCallback& aCallback) const
       
   168     {    
       
   169     return ResponseToRefreshL(aDialog,
       
   170                               aElements,
       
   171 		                      aRequestId,
       
   172                               aRefreshId,
       
   173                               aCallback,                              
       
   174                               *this,
       
   175                               *this,                               
       
   176                               *iTerminated);
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CDialogConfirmed::IncomingRequestL
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 TBool CDialogConfirmed::IncomingRequestL(CSIPDialogImplementation& aDialog,
       
   184                                          CSIPServerTransaction* aTransaction,
       
   185                                          CConnectionCallback& aCallback) const
       
   186     {
       
   187     __SIP_ASSERT_LEAVE(aTransaction, KErrArgument);
       
   188     return RequestReceivedL(aDialog, aTransaction, aCallback);
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CDialogConfirmed::SendAckL
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 void CDialogConfirmed::SendAckL(CSIPInviteDialogAssoc& aAssoc,
       
   196                                 const CSIPClientTransaction& aTransaction,
       
   197 			                    CSIPMessageElements* aElements) const
       
   198     {
       
   199     aAssoc.DoSendAckL(aTransaction, aElements);
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CDialogConfirmed::SendResponseL
       
   204 // Even when sending an error response to the initial request, dialog doesn't
       
   205 // enter terminated state, if it currently is in confirmed state.
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 void CDialogConfirmed::SendResponseL(CSIPDialogImplementation& aDialog,
       
   209                                      const CSIPResponseElements& aElements,
       
   210 						             TUint32 aRequestId,
       
   211                                      TBool /*aAffectsDialogState*/,
       
   212                                      TBool aTargetRefresh) const
       
   213     {
       
   214     SendResponseWithinDialogL(aDialog, aElements, aRequestId, aTargetRefresh);
       
   215     }
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CDialogConfirmed::SendPrackL
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 CSIPClientTransaction*
       
   222 CDialogConfirmed::SendPrackL(CSIPInviteDialogAssoc& aAssoc,
       
   223                              CSIPMessageElements* aElements) const
       
   224     {
       
   225     return aAssoc.DoSendRequestWithinDialogL(
       
   226     							SIPStrings::StringF(SipStrConsts::EPrack),
       
   227 								aElements);    
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CDialogConfirmed::SendUpdateL
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 CSIPClientTransaction*
       
   235 CDialogConfirmed::SendUpdateL(CSIPInviteDialogAssoc& aAssoc,
       
   236                               CSIPMessageElements* aElements) const
       
   237     {
       
   238     return aAssoc.DoSendRequestWithinDialogL(
       
   239     							SIPStrings::StringF(SipStrConsts::EUpdate),
       
   240 								aElements);    
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CDialogConfirmed::SendByeL
       
   245 // Either caller or callee can send BYE in Confirmed state.
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 CSIPClientTransaction*
       
   249 CDialogConfirmed::SendByeL(CSIPInviteDialogAssoc& aAssoc,
       
   250                            CSIPMessageElements* aElements) const
       
   251     { 
       
   252     return aAssoc.DoSendRequestWithinDialogL(
       
   253 	    							SIPStrings::StringF(SipStrConsts::EBye),
       
   254 									aElements);
       
   255     }
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CDialogConfirmed::SendUnsubscribeL
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 CSIPClientTransaction*
       
   262 CDialogConfirmed::SendUnsubscribeL(CSIPSubscribeDialogAssoc& aAssoc,
       
   263                                    CSIPMessageElements* aElements) const
       
   264     {
       
   265     return aAssoc.DoSendUnsubscribeL(aElements);
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CDialogConfirmed::SendNotifyL
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 CSIPClientTransaction*
       
   273 CDialogConfirmed::SendNotifyL(CSIPNotifyDialogAssoc& aAssoc,
       
   274                     		  CSIPMessageElements* aElements) const
       
   275 	{	
       
   276 	return aAssoc.DoSendNotifyWithinDialogL(aElements);
       
   277 	}
       
   278 
       
   279 // -----------------------------------------------------------------------------
       
   280 // CDialogConfirmed::SendReferL
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 CSIPClientTransaction*
       
   284 CDialogConfirmed::SendReferL(const CSIPDialogImplementation& /*aDialog*/,
       
   285 							 CSIPReferDialogAssoc& aAssoc,
       
   286                    		     CSIPMessageElements* aElements) const
       
   287   	{
       
   288 	return aAssoc.DoSendReferL(aElements, ETrue);
       
   289   	}
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CDialogConfirmed::ErrorOccured
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 TBool CDialogConfirmed::ErrorOccured(CSIPDialogImplementation& aDialog,
       
   296                                      TInt aError,
       
   297                                      TUint32 aRequestId,
       
   298                                      CConnectionCallback& aCallback) const
       
   299     {    
       
   300     return HandleErrorOccurred(aDialog,
       
   301                                aError,
       
   302                                aRequestId,
       
   303                                aCallback,
       
   304                                *iTerminated);
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CDialogConfirmed::ErrorOccured
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 TBool CDialogConfirmed::ErrorOccured(CSIPDialogImplementation& aDialog,
       
   312                                      TInt aError,
       
   313                                      TUint32 aRefreshId,
       
   314                                      TUint32 /*aRequestId*/,
       
   315                                      CConnectionCallback& aCallback) const
       
   316     {    
       
   317     return HandleRefreshErrorOccurred(aDialog,
       
   318                                		  aError,
       
   319                                		  aRefreshId,
       
   320                                		  aCallback,
       
   321                                		  *iTerminated);
       
   322     }
       
   323 
       
   324 // -----------------------------------------------------------------------------
       
   325 // CDialogConfirmed::ConnectionLost
       
   326 // This is the only case where dialog goes from confirmed to terminated state.
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CDialogConfirmed::ConnectionLost(CSIPDialogImplementation& aDialog) const
       
   330     {
       
   331     aDialog.ChangeState(iTerminated);
       
   332     }