S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SIPExStateIdle.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : SIPExStateIdle.cpp
00004 *  Part of     : SIPExEngine
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDES
00017 #include    "SIPExStateIdle.h"
00018 #include    "SIPExGameEngine.h"
00019 #include    "SIPExSIPEngine.h"
00020 
00021 // -----------------------------------------------------------------------------
00022 // TSIPExStateIdle::EnableProfile
00023 // Notifies the UI, signals SIP engine to enable profile and changes the active
00024 // state to the Registering. If no registration is needed the state is changed
00025 // straight to the Registered.
00026 // -----------------------------------------------------------------------------
00027 //
00028 void TSIPExStateIdle::EnableProfileL( CSIPExEngine* aContext )
00029     {
00030     // Notify UI
00031     aContext->InfoL( KEnablingProfile() );
00032 
00033     // The registration is required
00034     if( !aContext->SIPEngine()->EnableProfileL() )
00035         {
00036         ChangeState( aContext, aContext->iStateRegistering );
00037         }
00038     // The profile was succesfully enabled and registered
00039     else
00040         {
00041         aContext->InfoL( KProfileEnabled() );
00042         ChangeState( aContext, aContext->iStateRegistered );
00043         }
00044     }
00045 
00046 // -----------------------------------------------------------------------------
00047 // TSIPExStateIdle::SessionEnded
00048 // Notifies the UI.
00049 // -----------------------------------------------------------------------------
00050 //
00051 void TSIPExStateIdle::SessionEnded( CSIPExEngine* aContext )
00052     {
00053     // Keep track whether session ended while accept dialog was shown to user.
00054     iEnded = ETrue;
00055     
00056     Info( aContext, KSessionEnded() );
00057     }
00058 
00059 // -----------------------------------------------------------------------------
00060 // TSIPExStateIdle::InviteReceived
00061 // The acceptance is asked from the user and if accepted we reset game, start
00062 // listening socket and signal the SIP engine to send Accepted to the remote
00063 // peer.
00064 // -----------------------------------------------------------------------------
00065 //   
00066 void TSIPExStateIdle::InviteReceived( 
00067     CSIPExEngine* aContext, 
00068     const TDesC8& aFrom, 
00069     const TUint32 aIapId )
00070     {
00071     iEnded = EFalse;
00072     
00073     TBool retVal( EFalse );
00074     TRAPD( ignore, retVal = aContext->AcceptInvitationL( aFrom ) );
00075     if ( iEnded )
00076         {
00077         return;
00078         }
00079     if( retVal )
00080         {
00081         ChangeState( aContext, aContext->iStateAcceptingSIP );
00082         // The game data is reseted
00083         aContext->ResetGame();
00084         // The role for the peer is set
00085         aContext->SetPeer( CSIPExEngine::EServer );
00086         // Start listen incoming connections
00087         TInetAddr addr;
00088         TRAP( ignore, 
00089                 addr = aContext->SocketEngineL()->StartListeningL( aIapId ) );
00090         // Signal SIP engine
00091         TRAP( ignore, aContext->SIPEngine()->AcceptInviteL( addr ) );
00092         Info( aContext, KWaitingRemoteConn() );
00093         }
00094     else 
00095         {
00096         // Signal SIP engine
00097         TRAP( ignore, aContext->SIPEngine()->DeclineInviteL() );
00098         Info( aContext, KInviteDeclined() );
00099         }
00100     }
00101 
00102 // End of file
00103 

© Nokia 2006

Back to top