realtimenetprots/sipfw/SampleApp/sipengine/src/SIPExSIPServerOfferingState.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	"SIPExSIPServerOfferingState.h"
       
    21 #include	"SIPExSIPEngine.h"
       
    22 
       
    23 #include <sipstrings.h>
       
    24 #include <sipstrconsts.h>
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CSIPExSIPServerOfferingState::CSIPExSIPServerOfferingState
       
    30 // (other items were commented in a header).
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CSIPExSIPServerOfferingState::CSIPExSIPServerOfferingState()
       
    34 	{
       
    35 	}
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CSIPExSIPServerOfferingState::~CSIPExSIPServerOfferingState
       
    39 // (other items were commented in a header).
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CSIPExSIPServerOfferingState::~CSIPExSIPServerOfferingState()
       
    43 	{
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSIPExSIPServerOfferingState::NewL()
       
    48 // (other items were commented in a header).
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CSIPExSIPServerOfferingState* CSIPExSIPServerOfferingState::NewL()
       
    52 	{
       
    53 	CSIPExSIPServerOfferingState* self =
       
    54 		new (ELeave) CSIPExSIPServerOfferingState();
       
    55 	return self;
       
    56 	}
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSIPExSIPServerOfferingState::LinkStates()
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CSIPExSIPServerOfferingState::LinkStates(
       
    64 	CSIPExSIPStateBase& aServerEstablishingState,
       
    65 	CSIPExSIPStateBase& aTerminatedState )
       
    66 	{
       
    67 	iServerEstablishingState = &aServerEstablishingState;
       
    68 	iTerminatedState = &aTerminatedState;
       
    69 	}
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CSIPExSIPServerOfferingState::ByeReceivedL()
       
    73 // (other items were commented in a header).
       
    74 // -----------------------------------------------------------------------------
       
    75 void CSIPExSIPServerOfferingState::ByeReceivedL(
       
    76 	CSIPExSIPEngine& aEngine,
       
    77 	CSIPServerTransaction& aTransaction )
       
    78 	{
       
    79 	// Create and send response
       
    80     CSIPResponseElements* elem = 
       
    81         CSIPResponseElements::NewLC( 
       
    82             200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) );
       
    83     aTransaction.SendResponseL( elem );
       
    84     CleanupStack::Pop( elem );
       
    85 
       
    86 	// Inform observer
       
    87 	aEngine.Observer()->SessionEnded();
       
    88 	
       
    89 	// Set state
       
    90 	aEngine.SetCurrentState( iTerminatedState );
       
    91 	}
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CSIPExSIPServerOfferingState::CancelReceivedL()
       
    95 // (other items were commented in a header).
       
    96 // -----------------------------------------------------------------------------
       
    97 void CSIPExSIPServerOfferingState::CancelReceivedL(
       
    98 	CSIPExSIPEngine& aEngine,
       
    99 	CSIPClientTransaction& /*aTransaction */ )
       
   100 	{
       
   101 	aEngine.Observer()->SessionEnded();
       
   102 	aEngine.SetCurrentState( iTerminatedState );
       
   103 	}
       
   104 	
       
   105 // -----------------------------------------------------------------------------
       
   106 // CSIPExSIPServerOfferingState::AcceptInviteL()
       
   107 // (other items were commented in a header).
       
   108 // -----------------------------------------------------------------------------
       
   109 void CSIPExSIPServerOfferingState::AcceptInviteL( CSIPExSIPEngine& aEngine)
       
   110 	{
       
   111 	_LIT8( KMediaType, "application" );
       
   112 	_LIT8( KMediaSubType, "sdp" );
       
   113 	_LIT8( KLogEntry, "200 OK sent" );
       
   114 
       
   115 	// Get the current transaction
       
   116 	CSIPServerTransaction& tx = aEngine.ServerTx();
       
   117 	// Create the Response Elements object
       
   118     CSIPResponseElements* respElem =
       
   119     	CSIPResponseElements::NewLC( 
       
   120     	    200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) );
       
   121     
       
   122     // Set the message body - we need to communicate our IP Address
       
   123     CSIPMessageElements& msgElem = respElem->MessageElements();
       
   124 
       
   125 	CSdpDocument* sdpDocument = aEngine.SdpDocumentLC();
       
   126 	HBufC8* sdpBody = aEngine.SdpBodyL( sdpDocument );
       
   127 	CleanupStack::PushL( sdpBody );
       
   128 
       
   129    	CSIPContentTypeHeader* ct =
       
   130    		CSIPContentTypeHeader::NewLC( KMediaType, KMediaSubType );
       
   131 	msgElem.SetContentL( sdpBody, ct );
       
   132 
       
   133 	// Use the transaction to send 200 (OK)
       
   134 	tx.SendResponseL( respElem );
       
   135 
       
   136 	CleanupStack::Pop( ct );
       
   137 	CleanupStack::Pop( sdpBody );
       
   138 	CleanupStack::PopAndDestroy( sdpDocument );
       
   139 	CleanupStack::Pop( respElem );
       
   140 
       
   141 	aEngine.SetCurrentState( iServerEstablishingState );
       
   142 	aEngine.Observer()->WriteLog( KLogEntry );
       
   143 	}
       
   144 
       
   145 
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CSIPExSIPServerOfferingState::DeclineInviteL()
       
   149 // (other items were commented in a header).
       
   150 // -----------------------------------------------------------------------------
       
   151 void CSIPExSIPServerOfferingState::DeclineInviteL( CSIPExSIPEngine& aEngine )
       
   152 	{
       
   153 	// Get the current transaction
       
   154 	CSIPServerTransaction& tx = aEngine.ServerTx();
       
   155 	// Create the Response Elements object
       
   156     CSIPResponseElements* elem =
       
   157     	CSIPResponseElements::NewLC( 486, 
       
   158     	    SIPStrings::StringF( SipStrConsts::EPhraseBusyHere ) );
       
   159 
       
   160 	// Use the transaction to send 486 (Busy Here)
       
   161 	tx.SendResponseL( elem );
       
   162 
       
   163 	CleanupStack::Pop( elem );
       
   164 	aEngine.Observer()->SessionEnded();
       
   165 	aEngine.SetCurrentState( iTerminatedState );
       
   166 	}
       
   167