realtimenetprots/sipfw/SampleApp/sipengine/src/SIPExSIPClientOfferingState.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	"SIPExSIPClientOfferingState.h"
       
    21 #include	"SIPExSIPEngine.h"
       
    22 
       
    23 // ============================ MEMBER FUNCTIONS ===============================
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CSIPExSIPClientOfferingState::CSIPExSIPClientOfferingState
       
    27 // (other items were commented in a header).
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CSIPExSIPClientOfferingState::CSIPExSIPClientOfferingState()
       
    31 	{
       
    32 	}
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CSIPExSIPClientOfferingState::~CSIPExSIPClientOfferingState
       
    36 // (other items were commented in a header).
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C CSIPExSIPClientOfferingState::~CSIPExSIPClientOfferingState()
       
    40 	{
       
    41 	}
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CSIPExSIPClientOfferingState::NewL()
       
    45 // (other items were commented in a header).
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CSIPExSIPClientOfferingState* CSIPExSIPClientOfferingState::NewL()
       
    49 	{
       
    50 	CSIPExSIPClientOfferingState* self =
       
    51 		new (ELeave) CSIPExSIPClientOfferingState();
       
    52 	return self;
       
    53 	}
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSIPExSIPClientOfferingState::LinkStates()
       
    57 // (other items were commented in a header).
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 void CSIPExSIPClientOfferingState::LinkStates(
       
    61 	CSIPExSIPStateBase& aIdleState,
       
    62 	CSIPExSIPStateBase& aEstablishedState,
       
    63 	CSIPExSIPStateBase& aTerminatedState )
       
    64 	{
       
    65 	iIdleState = &aIdleState;
       
    66 	iEstablishedState = &aEstablishedState;
       
    67 	iTerminatedState = &aTerminatedState;
       
    68 	}
       
    69 
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CSIPExSIPClientOfferingState::CancelInviteL()
       
    73 // (other items were commented in a header).
       
    74 // -----------------------------------------------------------------------------
       
    75 void CSIPExSIPClientOfferingState::CancelInviteL( CSIPExSIPEngine& aEngine )
       
    76 	{
       
    77 	// Get the current Client Transaction
       
    78 	CSIPClientTransaction& clientTA = aEngine.ClientTx();
       
    79 
       
    80 	// Use it the to send CANCEL request
       
    81     CSIPClientTransaction* ta = clientTA.CancelL();
       
    82     delete ta;
       
    83 
       
    84 	aEngine.SetCurrentState( iIdleState );
       
    85 	aEngine.Observer()->InvitationCancelled();
       
    86 	}
       
    87 
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CSIPExSIPClientOfferingState::ResponseReceivedL()
       
    92 // (other items were commented in a header).
       
    93 // -----------------------------------------------------------------------------
       
    94 void CSIPExSIPClientOfferingState::ResponseReceivedL( 
       
    95     CSIPExSIPEngine& aEngine,
       
    96     CSIPClientTransaction& aTransaction )
       
    97 	{
       
    98 	const CSIPResponseElements* respElem = aTransaction.ResponseElements();
       
    99 
       
   100 	TUint statusCode = respElem->StatusCode();
       
   101 
       
   102 	if ( statusCode >= 200 && statusCode < 300 )
       
   103 		{
       
   104 		// Final Response received from network.
       
   105 		// Get the IP Address of the remote party from the Response Elements
       
   106 		const TInetAddr addr = 
       
   107 		            aEngine.IPAddressFromResponseElementsL( *respElem );
       
   108 
       
   109 
       
   110 		// Then, send ACK to remote party
       
   111 		CSIPInviteDialogAssoc& dialogAssoc = aEngine.DialogAssoc();
       
   112 		dialogAssoc.SendAckL( aTransaction );
       
   113 
       
   114         // Get used iap's id
       
   115 		TUint32 iapId( 0 );
       
   116 		CSIPConnection* conn = aEngine.DialogAssoc().Dialog().Connection();
       
   117 		if ( conn )
       
   118 		    {
       
   119 		    iapId = conn->IapId();
       
   120 		    }
       
   121 
       
   122 		// After ACKing, notify observer, giving IP Address and IAP id
       
   123 		// as parameter
       
   124 		aEngine.Observer()->InviteAcceptedByRemote( addr, iapId );
       
   125 
       
   126 
       
   127 		// Finally, change engine state
       
   128 		aEngine.SetCurrentState( iEstablishedState );
       
   129 		}
       
   130 	else if ( statusCode >= 100 && statusCode < 200 )
       
   131 		{
       
   132 		// Provisional Response received from network.
       
   133 		aEngine.Observer()->InviteReceivedByRemote( statusCode );
       
   134 		}
       
   135 	else
       
   136 		{
       
   137 		aEngine.Observer()->InviteDeclinedByRemote( statusCode );
       
   138 		aEngine.SetCurrentState( iTerminatedState );
       
   139 		}
       
   140 	}
       
   141 
       
   142 // End of file