realtimenetprots/sipfw/SampleApp/sipengine/src/SIPExSIPEstablishedState.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 
       
     2 // Copyright (c) 2004-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 //
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include	"SIPExSIPEstablishedState.h"
       
    21 #include	"SIPExSIPEngine.h"
       
    22 
       
    23 #include <sipstrings.h>
       
    24 #include <sipstrconsts.h>
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CSIPExSIPEstablishedState::CSIPExSIPEstablishedState
       
    30 // (other items were commented in a header).
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CSIPExSIPEstablishedState::CSIPExSIPEstablishedState()
       
    34 	{
       
    35 	}
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CSIPExSIPEstablishedState::~CSIPExSIPEstablishedState
       
    39 // (other items were commented in a header).
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CSIPExSIPEstablishedState::~CSIPExSIPEstablishedState()
       
    43 	{
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSIPExSIPEstablishedState::NewL()
       
    48 // (other items were commented in a header).
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CSIPExSIPEstablishedState* CSIPExSIPEstablishedState::NewL()
       
    52 	{
       
    53 	CSIPExSIPEstablishedState* self =
       
    54 		new (ELeave) CSIPExSIPEstablishedState();
       
    55 	return self;
       
    56 	}
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSIPExSIPEstablishedState::LinkStates()
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CSIPExSIPEstablishedState::LinkStates(
       
    64 	CSIPExSIPStateBase& aTerminatingState,
       
    65 	CSIPExSIPStateBase& aTerminatedState )
       
    66 	{
       
    67 	iTerminatingState = &aTerminatingState;
       
    68 	iTerminatedState = &aTerminatedState;
       
    69 	}
       
    70 
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // CSIPExSIPEstablishedState::EndSessionL()
       
    74 // (other items were commented in a header).
       
    75 // -----------------------------------------------------------------------------
       
    76 void CSIPExSIPEstablishedState::EndSessionL( CSIPExSIPEngine& aEngine )
       
    77 	{
       
    78 	// Get the current Dialog Association
       
    79 	CSIPInviteDialogAssoc& dialogAssoc = aEngine.DialogAssoc();
       
    80 	// Create the Message Elements object
       
    81 	CSIPMessageElements* msgElements = aEngine.CreateMessageElementsLC();
       
    82 
       
    83 	// Use the Dialog Association to send BYE request
       
    84 	CSIPClientTransaction* tx = dialogAssoc.SendByeL( msgElements );
       
    85 	aEngine.SetClientTx( tx );
       
    86 
       
    87 	CleanupStack::Pop( msgElements );
       
    88 
       
    89 	aEngine.SetCurrentState( iTerminatingState );
       
    90 	}
       
    91 
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CSIPExSIPEstablishedState::ByeReceivedL()
       
    95 // (other items were commented in a header).
       
    96 // -----------------------------------------------------------------------------
       
    97 void CSIPExSIPEstablishedState::ByeReceivedL(
       
    98 	CSIPExSIPEngine& aEngine,
       
    99 	CSIPServerTransaction& aTransaction )
       
   100 	{
       
   101 	// Create and send response
       
   102     CSIPResponseElements* elem = 
       
   103         CSIPResponseElements::NewLC( 
       
   104             200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) );
       
   105     aTransaction.SendResponseL( elem );
       
   106     CleanupStack::Pop( elem );
       
   107 
       
   108 	// Inform observer
       
   109 	aEngine.Observer()->SessionEnded();
       
   110 
       
   111 	// Set state ???
       
   112 	aEngine.SetCurrentState( iTerminatedState );
       
   113 	}
       
   114 
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CSIPExSIPEstablishedState::ResponseReceivedL()
       
   118 // (other items were commented in a header).
       
   119 // -----------------------------------------------------------------------------
       
   120 void CSIPExSIPEstablishedState::ResponseReceivedL(
       
   121 	CSIPExSIPEngine& aEngine,
       
   122 	CSIPClientTransaction& aTransaction )
       
   123 	{
       
   124 	// We might receive some 200 (OK) responses from the network
       
   125 	// after the session has been established. These should be
       
   126 	// ACKed, other responses indicate errors.
       
   127 
       
   128 	const CSIPResponseElements* respElem = aTransaction.ResponseElements();
       
   129 
       
   130 	TUint statusCode = respElem->StatusCode();
       
   131 
       
   132 	if ( statusCode >= 200 && statusCode < 300 )
       
   133 		{
       
   134 		// Send ACK to remote party
       
   135 		CSIPInviteDialogAssoc& dialogAssoc = aEngine.DialogAssoc();
       
   136 		dialogAssoc.SendAckL( aTransaction );
       
   137 		}
       
   138 	else
       
   139 		{
       
   140 		aEngine.Observer()->EngineError( statusCode );
       
   141 		}
       
   142 	}
       
   143 
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CSIPExSIPStateBase::AckReceivedL()
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 void CSIPExSIPEstablishedState::AckReceivedL(
       
   150 	CSIPExSIPEngine& aEngine,
       
   151 	CSIPServerTransaction& /* aTransaction */)
       
   152 	{
       
   153 	aEngine.Observer()->InviteAcceptedByUs();
       
   154 	}
       
   155 	
       
   156 // End of file