realtimenetprots/sipfw/SampleApp/gameengine/Src/SIPExStateAcceptingSIP.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 // INCLUDES
       
    20 #include    "SIPExStateAcceptingSIP.h"
       
    21 #include    "SIPExGameEngine.h"
       
    22 #include    "SIPExSIPEngine.h"
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // TSIPExState::SocketState
       
    26 // Changes the active state according the new state of the Socket engine.
       
    27 // If the socket is connected the game is reseted first and the turn is given
       
    28 // to the remote peer.
       
    29 // If not connected, info UI and set Registered to a new active state.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 void TSIPExStateAcceptingSIP::SocketState( 
       
    33     CSIPExEngine* aContext, 
       
    34     TInt aNewState )
       
    35     {
       
    36     aContext->SetPeer( CSIPExEngine::EServer );
       
    37     switch (aNewState)
       
    38         {
       
    39         case CSIPExSocketEngine::ENotConnected:
       
    40             ChangeState( aContext, aContext->iStateRegistered );
       
    41             aContext->InfoL( KNotConnected() );
       
    42             break;
       
    43         case CSIPExSocketEngine::EConnected:
       
    44             aContext->ResetGame();
       
    45             ChangeState( aContext, aContext->iStateRemote );
       
    46             aContext->StatusInfoL( KWaitingRemote() );
       
    47             aContext->InfoL( KConnected() );
       
    48             break;
       
    49 
       
    50         case CSIPExSocketEngine::ETimedOut:
       
    51             ChangeState( aContext, aContext->iStateRegistered );
       
    52             aContext->InfoL( KTimedOut() );
       
    53             break;
       
    54         default:
       
    55             break;
       
    56         }
       
    57     }
       
    58 
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // TSIPExStateAcceptingSIP::EndGameL
       
    62 // The SIP session will be ended.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void TSIPExStateAcceptingSIP::EndGameL( CSIPExEngine* aContext )
       
    66     {
       
    67     aContext->SIPEngine()->EndSessionL();
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // TSIPExStateAcceptingSIP::InvitationCancelled
       
    72 // The invitation is cancelled. The active state is changed to the registered
       
    73 // and the socket engine is destroyed.
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void TSIPExStateAcceptingSIP::InvitationCancelled( CSIPExEngine* aContext)
       
    77     {
       
    78     ChangeState( aContext, aContext->iStateRegistered );
       
    79     TRAPD( ignore, aContext->SocketEngineL()->Stop() );
       
    80     aContext->DestroySocketEngine();
       
    81     }
       
    82     
       
    83 // End of file