⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sipexsipserverofferingstate.cpp

📁 an example for sip for symbian
💻 CPP
字号:
/*
* ==============================================================================
*  Name        : SIPExSIPServerOfferingState.cpp
*  Part of     : SIPExSIPEngine
*  Interface   : 
*  Description : 
*  Version     : 
*
*  Copyright (c) 2004-2006 Nokia Corporation.
*  This material, including documentation and any related 
*  computer programs, is protected by copyright controlled by 
*  Nokia Corporation.
* ==============================================================================
*/

// INCLUDE FILES
#include	"SIPExSIPServerOfferingState.h"
#include	"SIPExSIPEngine.h"

#include <sipstrings.h>
#include <SipStrConsts.h>

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::CSIPExSIPServerOfferingState
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
CSIPExSIPServerOfferingState::CSIPExSIPServerOfferingState()
	{
	}

// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::~CSIPExSIPServerOfferingState
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C CSIPExSIPServerOfferingState::~CSIPExSIPServerOfferingState()
	{
	}

// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::NewL()
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C CSIPExSIPServerOfferingState* CSIPExSIPServerOfferingState::NewL()
	{
	CSIPExSIPServerOfferingState* self =
		new (ELeave) CSIPExSIPServerOfferingState();
	return self;
	}

// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::LinkStates()
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CSIPExSIPServerOfferingState::LinkStates(
	CSIPExSIPStateBase& aServerEstablishingState,
	CSIPExSIPStateBase& aTerminatedState )
	{
	iServerEstablishingState = &aServerEstablishingState;
	iTerminatedState = &aTerminatedState;
	}

// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::ByeReceivedL()
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPServerOfferingState::ByeReceivedL(
	CSIPExSIPEngine& aEngine,
	CSIPServerTransaction& aTransaction )
	{
	// Create and send response
    CSIPResponseElements* elem = 
        CSIPResponseElements::NewLC( 
            200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) );
    aTransaction.SendResponseL( elem );
    CleanupStack::Pop( elem );

	// Inform observer
	aEngine.Observer()->SessionEnded();
	
	// Set state
	aEngine.SetCurrentState( iTerminatedState );
	}

// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::CancelReceivedL()
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPServerOfferingState::CancelReceivedL(
	CSIPExSIPEngine& aEngine,
	CSIPClientTransaction& /*aTransaction */ )
	{
	aEngine.Observer()->SessionEnded();
	aEngine.SetCurrentState( iTerminatedState );
	}
	
// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::AcceptInviteL()
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPServerOfferingState::AcceptInviteL( CSIPExSIPEngine& aEngine)
	{
	_LIT8( KMediaType, "application" );
	_LIT8( KMediaSubType, "sdp" );
	_LIT8( KLogEntry, "200 OK sent" );

	// Get the current transaction
	CSIPServerTransaction& tx = aEngine.ServerTx();
	// Create the Response Elements object
    CSIPResponseElements* respElem =
    	CSIPResponseElements::NewLC( 
    	    200, SIPStrings::StringF( SipStrConsts::EPhraseOk ) );
    
    // Set the message body - we need to communicate our IP Address
    CSIPMessageElements& msgElem = respElem->MessageElements();

	CSdpDocument* sdpDocument = aEngine.SdpDocumentLC();
	HBufC8* sdpBody = aEngine.SdpBodyL( sdpDocument );
	CleanupStack::PushL( sdpBody );

   	CSIPContentTypeHeader* ct =
   		CSIPContentTypeHeader::NewLC( KMediaType, KMediaSubType );
	msgElem.SetContentL( sdpBody, ct );

	// Use the transaction to send 200 (OK)
	tx.SendResponseL( respElem );

	CleanupStack::Pop( ct );
	CleanupStack::Pop( sdpBody );
	CleanupStack::PopAndDestroy( sdpDocument );
	CleanupStack::Pop( respElem );

	aEngine.SetCurrentState( iServerEstablishingState );
	aEngine.Observer()->WriteLog( KLogEntry );
	}



// -----------------------------------------------------------------------------
// CSIPExSIPServerOfferingState::DeclineInviteL()
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPServerOfferingState::DeclineInviteL( CSIPExSIPEngine& aEngine )
	{
	// Get the current transaction
	CSIPServerTransaction& tx = aEngine.ServerTx();
	// Create the Response Elements object
    CSIPResponseElements* elem =
    	CSIPResponseElements::NewLC( 486, 
    	    SIPStrings::StringF( SipStrConsts::EPhraseBusyHere ) );

	// Use the transaction to send 486 (Busy Here)
	tx.SendResponseL( elem );

	CleanupStack::Pop( elem );
	aEngine.Observer()->SessionEnded();
	aEngine.SetCurrentState( iTerminatedState );
	}

// End of file

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -