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

📄 sipexsipengine.cpp

📁 an example for sip for symbian
💻 CPP
📖 第 1 页 / 共 3 页
字号:

// From MSIPConnectionObserver:

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::IncomingRequest
// No dialog has been established yet, so this should be an INVITE or MESSAGE.
// The ownership of aTransaction is transferred.
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::IncomingRequest( CSIPServerTransaction* aTransaction )
	{
    if ( aTransaction->Type() == SIPStrings::StringF( SipStrConsts::EInvite ) )
        {
		// An INVITE has been received.
		// Get profile, create connection, and let the
		// state machine handle it.

		if ( !iProfile )
			{
			// If the default profile isn't enabled, do it now
			TRAPD( err, EnableProfileL() );

			if ( err != KErrNone )
				{
				// A profile error occured.
				// Delete aTransaction and inform the observer.
				delete aTransaction;
				aTransaction = NULL;

				iObserver->ProfileError( err );
				}
			}

		// The transaction still exists, which means there
		// was no trouble with the profile part. Go on with
		// request handling.
		if ( aTransaction )
			{
			// The ownership of aTransaction is transferred.
			// Save the pointer for later queries and eventual
			// deletion.
			SetServerTx(aTransaction);

			// Handle the incoming request in the state machine classes
			// The ownership of aTransaction is transferred.
			TRAPD( err2, iCurrentState->InviteReceivedL( *this, aTransaction ));
			}
        }
    else if ( aTransaction->Type() == SIPStrings::StringF( SipStrConsts::EMessage ) )
    	{
    	// An Instant Message is received
		// The state machine isn't needed for this.
    	IMReceived( aTransaction );
    	}
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::IncomingRequest
// A request concerning an established dialog is received.
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::IncomingRequest( 
    CSIPServerTransaction* aTransaction,
	CSIPDialog& aDialog )
	{
	const RPointerArray<CSIPDialogAssocBase>& dialogAssoc =
    	aDialog.SIPDialogAssociations();

	for ( TInt i = 0; i < dialogAssoc.Count(); i++ )
		{
		if ( dialogAssoc[i]->Type() == 
		    SIPStrings::StringF( SipStrConsts::EInvite ) )
			{
			iDialogAssoc = 
			    reinterpret_cast<CSIPInviteDialogAssoc*>( dialogAssoc[0] );
			break;
			}
		}

    if ( aTransaction->Type() == SIPStrings::StringF( SipStrConsts::EBye ) )
        {
		// The ownership of aTransaction is transferred.
		// Save the pointer for later queries and eventual
		// deletion.
		SetServerTx(aTransaction);

        TRAPD( err, iCurrentState->ByeReceivedL( *this, *aTransaction ) );

        if ( err != KErrNone )
        	{
        	iObserver->EngineError( err );
        	}
        }
    else if ( aTransaction->Type() == 
        SIPStrings::StringF( SipStrConsts::EAck ) )
        {
		// The ownership of aTransaction is transferred.
		// Save the pointer for later queries and eventual
		// deletion.
		SetServerTx(aTransaction);

        TRAPD( err, iCurrentState->AckReceivedL( *this, *aTransaction ) );

        if ( err != KErrNone )
        	{
        	iObserver->EngineError( err );
        	}
        }
    else if ( aTransaction->Type() == 
        SIPStrings::StringF( SipStrConsts::EMessage ) )
    	{
    	IMReceived( aTransaction );
    	}
    else
        {
        // Unknown, or unimplemented, request received
		delete aTransaction;
		aTransaction = NULL;
        iObserver->EngineError( KErrNotSupported );
        }
	}

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::IncomingResponse - No implementation needed
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::IncomingResponse( 
    CSIPClientTransaction& /* aTransaction */ )
	{
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::IncomingResponse
// A response inside an established dialog is received.
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::IncomingResponse( CSIPClientTransaction& aTransaction,
										CSIPDialogAssocBase& aDialogAssoc )
	{
	if ( aDialogAssoc.Type() == SIPStrings::StringF( SipStrConsts::EInvite )  )
		{
		iDialogAssoc = reinterpret_cast<CSIPInviteDialogAssoc*>( &aDialogAssoc );
		}
	
	TRAPD( err, iCurrentState->ResponseReceivedL( *this, aTransaction ) );
	
	if ( err != KErrNone )
		{
		iObserver->EngineError( err );
		}
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::IncomingResponse
// Since the ownership is transferred, aDialogAssoc needs to be deleted
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::IncomingResponse( 
    CSIPClientTransaction& /* aTransaction */,
	CSIPInviteDialogAssoc* aDialogAssoc )
	{
	delete aDialogAssoc;
	aDialogAssoc = NULL;
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::IncomingResponse - No implementation needed
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::IncomingResponse( 
    CSIPClientTransaction& /* aTransaction */,
	CSIPRegistrationBinding& /* aRegistration */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ErrorOccured
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ErrorOccured( 
    TInt /* aError */,
	CSIPTransactionBase& /* aTransaction */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ErrorOccured
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ErrorOccured( 
    TInt /* aError */,
	CSIPClientTransaction& /* aTransaction */,
	CSIPRegistrationBinding& /* aRegistration */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ErrorOccured
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ErrorOccured( 
    TInt /* aError */,
	CSIPTransactionBase& /* aTransaction */,
	CSIPDialogAssocBase& /* aDialogAssoc */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ErrorOccured
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ErrorOccured( 
    TInt /* aError */, 
    CSIPRefresh& /* aSIPRefresh */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ErrorOccured
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ErrorOccured( 
    TInt /* aError */,
	CSIPRegistrationBinding& /* aRegistration */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ErrorOccured
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ErrorOccured( 
    TInt /* aError */,
	CSIPDialogAssocBase& /* aDialogAssoc */ )
	{
	
	}


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::InviteCompleted
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::InviteCompleted( 
    CSIPClientTransaction& /* aTransaction */ )
	{
	delete iClientTx;
	iClientTx = NULL;
	}

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::InviteCanceled
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::InviteCanceled( 
    CSIPServerTransaction& /* aTransaction */ )
    {
    delete iClientTx; 
	iClientTx = NULL;
    }

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ConnectionStateChanged
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ConnectionStateChanged( CSIPConnection::TState aState )
	{
	if ( iConnState == CSIPConnection::EActive &&
		 aState != CSIPConnection::EActive )
		{
		// A previously active connection is active no more
		iObserver->ConnectionLost();
		}
	else
		{
		iConnState = aState;
		}
	}



// From MSIPProfileRegistryObserver


// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ProfileRegistryErrorOccurred
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ProfileRegistryEventOccurred( 
    TUint32 aProfileId, 
    TEvent aEvent )
    {
    switch (aEvent)
	    {
	    case MSIPProfileRegistryObserver::EProfileRegistered:
	        {
	        HandleProfileRegistered( aProfileId );
	        break;
	        }
	    case MSIPProfileRegistryObserver::EProfileDeregistered:
	        {
	        HandleProfileDeregistered( aProfileId );
	        break;
	        }
	    case MSIPProfileRegistryObserver::EProfileDestroyed:
	        {
            HandleProfileDestroyed( aProfileId );
	        break;
	        }
	    default:
	        {
	        // MSIPProfileRegistryObserver::EProfileCreated and
	        // MSIPProfileRegistryObserver::EProfileUpdated
	        // are ignored
	        break;
	        }
	    }
    }

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::ProfileRegistryErrorOccurred
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::ProfileRegistryErrorOccurred( 
    TUint32 /* aSIPProfileId */,
	TInt aError )
	{
	iObserver->ProfileError( aError );
	}
	

	
// Private handling for profile events

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::HandleProfileRegistered
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::HandleProfileRegistered( TUint32 aSIPProfileId )
	{
    TUint32 profileId( 0 );
	iProfile->GetParameter( KSIPProfileId, profileId );
    if ( aSIPProfileId == profileId )
        {
		// The profile registration is complete
		// Inform the Engine Observer
		iObserver->ProfileEnabled( aSIPProfileId );
        }
	}
	
// -----------------------------------------------------------------------------
// CSIPExSIPEngine::HandleProfileDeregistered
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::HandleProfileDeregistered( TUint32 aSIPProfileId )
	{
	TUint32 profileId( 0 );
	iProfile->GetParameter( KSIPProfileId, profileId );
    if ( aSIPProfileId == profileId )
        {
		// The previously registered profile has
		// become unregistered.
    	delete iDialogAssoc;
    	iDialogAssoc = 0;
    	delete iConnection;
    	iConnection = 0;
    	//iNotOwnedConnection = 0;
    	delete iProfile;
    	iProfile = 0;
    	
    	iObserver->ProfileError( KErrGeneral );     	
        }
	}

// -----------------------------------------------------------------------------
// CSIPExSIPEngine::HandleProfileDestroyed
// (other items were commented in a header).
// -----------------------------------------------------------------------------
void CSIPExSIPEngine::HandleProfileDestroyed( TUint32 /* aSIPProfileId */ )
	{
	delete iDialogAssoc;
	iDialogAssoc = 0;
	delete iConnection;
	iConnection = 0;
	//iNotOwnedConnection = 0;
	delete iProfile;
	iProfile = 0;

	iObserver->ProfileError( KErrGeneral );
	}
	
// End of file

⌨️ 快捷键说明

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