callcontinuity/vcc/src/tvccstatefailing.cpp
branchRCL_3
changeset 21 f742655b05bf
parent 20 65a3ef1d5bd0
child 22 d38647835c2e
equal deleted inserted replaced
20:65a3ef1d5bd0 21:f742655b05bf
     1 /*
       
     2 * Copyright (c) 2008 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:   Implementation for the VCC Failing state
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "tvccstatefailing.h"
       
    21 #include "cvccperformer.h"
       
    22 #include "rubydebug.h"
       
    23 
       
    24 
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // c'tor
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 TVccStateFailing::TVccStateFailing()
       
    31 	{
       
    32 	RUBY_DEBUG_BLOCK( "TVccStateFailing::TVccStateFailing" );	
       
    33 	} 
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // Name
       
    37 // -----------------------------------------------------------------------------
       
    38 //	
       
    39 TUint TVccStateFailing::Name() const
       
    40 	{
       
    41 	RUBY_DEBUG_BLOCK( "TVccStateFailing::Name" );
       
    42 	return KVccStateFailing;
       
    43 	}
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // LinkState
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 void TVccStateFailing::LinkState( TVccState& aInit )
       
    50 	{
       
    51 	RUBY_DEBUG_BLOCK( "TVccStateFailing::LinkState" );
       
    52 	iInit = &aInit;	
       
    53 	}
       
    54 	
       
    55 // -----------------------------------------------------------------------------
       
    56 // CallStateChanged
       
    57 // -----------------------------------------------------------------------------
       
    58 //	
       
    59 void TVccStateFailing::CallStateChanged( CVccPerformer& aContext, 
       
    60                                 const MCCPCallObserver::TCCPCallState aState,
       
    61                                 MCCPCall* aCall )
       
    62 	{
       
    63 	RUBY_DEBUG_BLOCK( "TVccStateFailing::CallStateChanged" );
       
    64 	InspectChangedStates(aContext, 
       
    65 	                        aState, 
       
    66 	                        aCall, 
       
    67 	                        aContext.CallObserver(), 
       
    68 	                        &MCCPCallObserver::CallStateChanged);
       
    69 	}
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CallStateChangedWithInband
       
    73 // -----------------------------------------------------------------------------
       
    74 //  
       
    75 void TVccStateFailing::CallStateChangedWithInband( CVccPerformer& aContext, 
       
    76                                 const MCCPCallObserver::TCCPCallState aState,
       
    77                                 MCCPCall* aCall )
       
    78     {
       
    79     RUBY_DEBUG_BLOCK( "TVccStateFailing::CallStateChangedWithInband" );
       
    80     InspectChangedStates(aContext, 
       
    81                             aState, 
       
    82                             aCall, 
       
    83                             aContext.CallObserver(), 
       
    84                             &MCCPCallObserver::CallStateChangedWithInband);  
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // From MCCPCallObserver
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void TVccStateFailing::ErrorOccurred( CVccPerformer& aContext, 
       
    92                                 const TCCPError aError,
       
    93                                 MCCPCall* aCall )
       
    94     {
       
    95     RUBY_DEBUG_BLOCK( "TVccStateFailing::ErrorOccurred" );
       
    96     RUBY_DEBUG1( "TVccStateFailing::ErrorOccurred - error: %d", aError );
       
    97     __ASSERT_DEBUG( aContext.CallObserver()!=NULL, User::Invariant() );
       
    98     __ASSERT_DEBUG(aContext.PrimaryCall()!=NULL, User::Invariant());
       
    99     __ASSERT_DEBUG(aCall != NULL, User::Invariant());
       
   100     if( aCall == aContext.PrimaryCall() )
       
   101         {
       
   102         aContext.CallObserver()->ErrorOccurred( aError, aContext.PrimaryCall() );
       
   103         }
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // From MCCPCallObserver
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void TVccStateFailing::CallEventOccurred(CVccPerformer& aContext, 
       
   111                                 const MCCPCallObserver::TCCPCallEvent aEvent,
       
   112                                 MCCPCall* aCall )
       
   113     {
       
   114     RUBY_DEBUG_BLOCK( "TVccStateFailing::CallEventOccurred" ); 
       
   115 	__ASSERT_DEBUG(aContext.CallObserver()!=NULL, User::Invariant());
       
   116 	__ASSERT_DEBUG(aCall != NULL, User::Invariant());
       
   117 	__ASSERT_DEBUG(aContext.PrimaryCall()!=NULL, User::Invariant());
       
   118 	    
       
   119 	if( aCall == aContext.PrimaryCall() )
       
   120 	    {
       
   121 	    aContext.CallObserver()->CallEventOccurred( aEvent, aContext.PrimaryCall() );
       
   122 	    }
       
   123 	}
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CheckAndMoveToInit
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void TVccStateFailing::CheckAndMoveToInit(CVccPerformer& aContext, MCCPCall* aCall,
       
   130                                             const MCCPCallObserver::TCCPCallState aState)
       
   131     {
       
   132        RUBY_DEBUG_BLOCK( "TVccStateFailing::CheckAndmoveToInit" ); 
       
   133         
       
   134        if ( !aContext.SecondaryCall() )
       
   135            {
       
   136            RUBY_DEBUG0( "Secondary call not exist - setting state to init");
       
   137            aContext.SetState(*iInit);
       
   138            }
       
   139        
       
   140  else  if ( aCall == aContext.SecondaryCall() )
       
   141            {
       
   142            if( aState == MCCPCallObserver::ECCPStateDisconnecting || 
       
   143                    aState == MCCPCallObserver::ECCPStateIdle )
       
   144                {
       
   145                RUBY_DEBUG0( "Secondary call is disconnecting or idle - setting state to init");
       
   146                aContext.SetState(*iInit);
       
   147                }
       
   148            }
       
   149      }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // InspectChangedStates
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void TVccStateFailing::InspectChangedStates (CVccPerformer& aContext, 
       
   156                                const MCCPCallObserver::TCCPCallState aState,
       
   157                                MCCPCall* aCall,
       
   158                                MCCPCallObserver* aCallee,
       
   159                                void( MCCPCallObserver::*aCallback)
       
   160                                (const MCCPCallObserver::TCCPCallState, MCCPCall*))
       
   161     {
       
   162     __ASSERT_DEBUG( aContext.PrimaryCall() != NULL, User::Invariant() );
       
   163     __ASSERT_DEBUG(aCall != NULL, User::Invariant());
       
   164 
       
   165     RUBY_DEBUG1("call state is: %d", aState);
       
   166     // Remote party has disconnected the call during the handover
       
   167     if( aState == MCCPCallObserver::ECCPStateDisconnecting &&
       
   168         aCall == aContext.SecondaryCall() )
       
   169         {
       
   170         ReleaseCall(aContext, *aContext.SecondaryCall(), *iInit, KVccHoNok );
       
   171         }
       
   172     else if (aCall == aContext.PrimaryCall())
       
   173         {
       
   174         //events related to the old leg, so pass them to the telephony.
       
   175         (aCallee->*aCallback)( aState, aContext.PrimaryCall());
       
   176         }
       
   177             
       
   178     CheckAndMoveToInit( aContext, aCall, aState );
       
   179     }