sipvoipprovider/src/svpsessionbase.cpp
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006-2010 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:  Session base class for SVP MO and MT sessions. Contains methods 
       
    15 *                common for SVP MO and MT sessions.
       
    16 *
       
    17 */
       
    18 
       
    19 #include <e32math.h>
       
    20 #include <escapeutils.h>
       
    21 
       
    22 #include <mcetransactiondatacontainer.h>
       
    23 #include <mceaudiostream.h>
       
    24 #include <mcertpsink.h>
       
    25 #include <mcertpsource.h>
       
    26 #include <mceaudiocodec.h>
       
    27 #include <mcedefs.h>
       
    28 #include <mcesecuresession.h> 
       
    29 #include <mcesecureoutsession.h>
       
    30 #include <mcesecureinsession.h>
       
    31 #include <mcemicsource.h>
       
    32 #include <mcespeakersink.h>
       
    33 #include <siperr.h>
       
    34 #include <telephonydomainpskeys.h> // for mute 
       
    35 
       
    36 #include "svpsessionbase.h"
       
    37 #include "svpholdcontroller.h"
       
    38 #include "svptransfercontroller.h"
       
    39 #include "svptransferstatecontext.h"
       
    40 #include "svptimer.h"
       
    41 #include "svpsipconsts.h"
       
    42 #include "svpuriparser.h"
       
    43 #include "svpaudioutility.h"
       
    44 #include "svpvolumeobserver.h"
       
    45 #include "svplogger.h"
       
    46 #include "svputility.h"
       
    47 #include "svprtpobserver.h"
       
    48 #include "svppropertywatch.h"
       
    49 #include "svpdtmfeventgenerator.h"
       
    50 
       
    51 
       
    52 // Local Consts
       
    53 const TInt KMaxTimerValueMO = 4000;
       
    54 const TInt KMinTimerValueMO = 2100;
       
    55 const TInt KMaxTimerValueMT = 2000;
       
    56 const TInt KMinTimerValueMT = 10;
       
    57 
       
    58 const TInt KRandomDividerOne = 1000000;
       
    59 const TInt KRandomDividerTwo = 1000;
       
    60 
       
    61 const TInt KMaxPhoneVolume = 10;
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CSVPSessionBase::CSVPSessionBase
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CSVPSessionBase::CSVPSessionBase( TMceTransactionDataContainer& aContainer,
       
    68     MSVPSessionObserver& aObserver, CSVPUtility& aSVPUtility,
       
    69     CSVPRtpObserver& aRtpObserver ) :
       
    70     iSVPUtility( aSVPUtility ),
       
    71     iRtpObserver( aRtpObserver ),
       
    72     iContainer( aContainer ),
       
    73     iObserver( aObserver ),
       
    74     iErrorInULandDLFirstTime ( ETrue ),
       
    75     iEarlyMediaOngoing ( EFalse )
       
    76     {
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CSVPSessionBase::~CSVPSessionBase
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CSVPSessionBase::~CSVPSessionBase()
       
    84     {
       
    85     SVPDEBUG1( "SVPSessionBase::~CSVPSessionBase In" )
       
    86     
       
    87     delete iCallParameters;
       
    88     
       
    89     delete iHoldController;
       
    90     
       
    91     iObserver.RemoveFromArray( *this );
       
    92     
       
    93     delete iSession;
       
    94     
       
    95     StopTimers();
       
    96     
       
    97     iTimers.Close();
       
    98     
       
    99     delete iRecipient;
       
   100     
       
   101     delete iDisplayName;
       
   102     
       
   103     delete iTransferController;
       
   104     
       
   105     delete iMutePropertyWatch;
       
   106     
       
   107     delete iVolObserver;
       
   108     
       
   109     delete iFromHeader;
       
   110     
       
   111     delete iToHeader;
       
   112     
       
   113     delete iCallId;
       
   114     
       
   115     delete iCSeqHeader;
       
   116     
       
   117     delete iEventGenerator;
       
   118     
       
   119     delete (iTempSecSession != iSession ? iTempSecSession : NULL );
       
   120     
       
   121     delete iDtmfString;
       
   122     
       
   123     SVPDEBUG1( "CSVPSessionBase::~CSVPSessionBase Out" )
       
   124     }
       
   125    
       
   126 // ---------------------------------------------------------------------------
       
   127 // CSVPSessionBase::ReleaseTempSecure
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CSVPSessionBase::ReleaseTempSecure()
       
   131     {
       
   132     delete iTempSecSession;
       
   133     iTempSecSession = NULL;
       
   134     }
       
   135     
       
   136 // ---------------------------------------------------------------------------
       
   137 // CSVPSessionBase::Session
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 const CMceSession& CSVPSessionBase::Session() const   
       
   141     {
       
   142     return *iSession;
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // CSVPSessionBase::StartTimerL
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CSVPSessionBase::StartTimerL( TInt aMilliSeconds, TInt aTimerId )
       
   150     {
       
   151     SVPDEBUG1( "CSVPSessionBase::StartTimerL In" )
       
   152     
       
   153     CSVPTimer* timer = CSVPTimer::NewL( *this, aTimerId );
       
   154     CleanupStack::PushL( timer );
       
   155     timer->SetTime( aMilliSeconds );
       
   156     iTimers.AppendL( timer );
       
   157     CleanupStack::Pop( timer );
       
   158     
       
   159     SVPDEBUG1( "CSVPSessionBase::StartTimerL Out" )
       
   160     }
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // CSVPSessionBase::StopTimers
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CSVPSessionBase::StopTimers()
       
   167     {
       
   168     SVPDEBUG1( "CSVPSessionBase::StopTimers In" )
       
   169     
       
   170     while ( iTimers.Count() )
       
   171         {
       
   172         iTimers[0]->Stop();
       
   173         delete iTimers[0];
       
   174         iTimers.Remove( 0 );
       
   175         }
       
   176     
       
   177     SVPDEBUG1( "CSVPSessionBase::StopTimers Out" )
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CSVPSessionBase::ReinviteCrossoverTime
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 TInt CSVPSessionBase::ReinviteCrossoverTime()
       
   185     {
       
   186     SVPDEBUG1( "CSVPSessionBase::ReinviteCrossoverTime In" )
       
   187     
       
   188     TInt maxValue( 0 );
       
   189     TInt minValue( 0 );
       
   190     
       
   191     if ( IsMobileOriginated() )
       
   192         {
       
   193         minValue = KMinTimerValueMO;
       
   194         maxValue = KMaxTimerValueMO;
       
   195         }
       
   196     else
       
   197         {
       
   198         minValue = KMinTimerValueMT;
       
   199         maxValue = KMaxTimerValueMT; 
       
   200         }
       
   201     
       
   202     TInt timerValue( 0 );
       
   203     TTime time;
       
   204     time.HomeTime();
       
   205     TInt64 seed( time.Int64() );
       
   206     
       
   207     for ( TInt i = 0; i < ( maxValue - minValue ); i++ )
       
   208         {
       
   209         TInt random = Math::Rand( seed );
       
   210         TReal random2 =  ( TReal )random / KRandomDividerOne;
       
   211         TInt random3 = ( TInt )( minValue * random2 ) / KRandomDividerTwo;
       
   212         
       
   213         if ( minValue <= random3 && minValue >= random3 )
       
   214             {
       
   215             timerValue = random3;
       
   216             break;
       
   217             }
       
   218         }
       
   219     
       
   220     SVPDEBUG2("CSVPSessionBase::ReinviteCrossoverTime Out return: %d", timerValue )
       
   221     return timerValue;    
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CSVPSessionBase::StopTimer
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CSVPSessionBase::StopTimer( TInt aTimerId )
       
   229     {
       
   230     SVPDEBUG2( "CSVPSessionBase::StopTimer In, Timer -- ID: %d", aTimerId )
       
   231 
       
   232     // Find the timer and delete it.
       
   233     for ( TInt t = 0; t < iTimers.Count(); )
       
   234         {
       
   235         if ( iTimers[ t ] ->Id() == aTimerId )
       
   236             {
       
   237             iTimers[t]->Stop();
       
   238             delete iTimers[ t ];
       
   239             iTimers.Remove( t );
       
   240             }
       
   241         else
       
   242             {
       
   243             t++;
       
   244             }
       
   245         }
       
   246     
       
   247     SVPDEBUG1( "CSVPSessionBase::StopTimer Out" )
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // CSVPSessionBase::TimedOut
       
   252 // ---------------------------------------------------------------------------
       
   253 //    
       
   254 void CSVPSessionBase::TimedOut( TInt aTimerId )
       
   255     {
       
   256     SVPDEBUG1( "CSVPSessionBase::TimedOut In" )
       
   257      
       
   258     // Find the timer and delete it.
       
   259     for ( TInt t = 0; t < iTimers.Count(); )
       
   260         {
       
   261         if ( iTimers[ t ] ->Id() == aTimerId )
       
   262             {
       
   263             delete iTimers[ t ];
       
   264             iTimers.Remove( t );
       
   265             }
       
   266         else
       
   267             {
       
   268             t++;
       
   269             }
       
   270         }
       
   271     
       
   272     if ( KSVPInviteTimerExpired == aTimerId )
       
   273         {
       
   274         // INVITE timer expired, notify client
       
   275         SVPDEBUG1( "CSVPSessionBase::TimedOut Invite timer expired, callback" )
       
   276         ExecCbErrorOccurred( ECCPErrorNotResponding );
       
   277         
       
   278         // send cancel
       
   279         TRAPD( errCancel, static_cast< CMceOutSession* >( iSession )->CancelL() );
       
   280         
       
   281         if ( errCancel )
       
   282             {
       
   283             SVPDEBUG2( "CSVPSessionBase::TimedOut Cancel: %d", errCancel )
       
   284             }
       
   285         
       
   286         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
   287 
       
   288         TRAPD( errTimer, StartTimerL( KSVPTerminatingTime, KSVPRemoteEndDiedExpired ));
       
   289 	    if ( errTimer )
       
   290 		    {
       
   291 			SVPDEBUG2("CSVPSessionBase::No Answer timer leave with error code %d",
       
   292 			        errTimer )
       
   293             }
       
   294         }
       
   295     
       
   296     if ( KSVPTerminationTimerExpired == aTimerId )
       
   297         {
       
   298         // Renew terminating timer to keep session alive when incoming 
       
   299         // transfer ongoing, not longer than max default expire time (120s)
       
   300         if ( IsIncomingTransfer() &&
       
   301              !IsAttended() &&
       
   302              iTerminatingRepeat < KSVPDefaultExpiresTime )
       
   303             {
       
   304             SVPDEBUG2( "CSVPSessionBase::TimedOut UnAtte case iTerminatingRepeat = %d",
       
   305                 iTerminatingRepeat )
       
   306             
       
   307             // Continue timeout time if the new session of the 
       
   308             // incoming transfer not yet established
       
   309             iTerminatingRepeat = iTerminatingRepeat +
       
   310                 KSVPTerminatingTime / KSVPMilliSecondCoefficient;
       
   311             
       
   312             TRAPD( errTimer, StartTimerL( KSVPTerminatingTime,
       
   313                     KSVPTerminationTimerExpired ) );
       
   314             
       
   315             if ( errTimer )
       
   316                 {
       
   317                 SVPDEBUG2( "CSVPSessionBase::TimedOut Termination leave with code %d",
       
   318                         errTimer )
       
   319                 }
       
   320             }
       
   321         else
       
   322             {
       
   323             SVPDEBUG1( "CSVPSessionBase::TimedOut Termination timer, callback" )
       
   324             ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   325             }
       
   326         }
       
   327     
       
   328     if ( KSVPRemoteEndDiedExpired == aTimerId )    
       
   329         {
       
   330         SVPDEBUG1( "CSVPSessionBase::TimedOut remote end died, callback" )
       
   331         // disconnecting state callback sent before timer started
       
   332         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   333         }
       
   334     
       
   335     if ( KSVPHangUpTimerExpired == aTimerId )    
       
   336         {
       
   337         SVPDEBUG1( "CSVPSessionBase::TimedOut HangUp timer expired, callback" )
       
   338         // disconnecting state callback sent before timer started
       
   339         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   340         }
       
   341     
       
   342     if ( KSVPExpiresTimeExpired == aTimerId )
       
   343         {
       
   344         SVPDEBUG1( "CSVPSessionBase::TimedOut expires timer expired" )
       
   345         // send 487
       
   346         TRAPD( err, static_cast<CMceInSession*>( iSession )->RespondL(
       
   347                 KSVPRequestTerminatedReason, KSVPRequestTerminatedVal ) );
       
   348         
       
   349         if ( err )
       
   350             {
       
   351             // sending response failed
       
   352             // not serious because session is put to idle state anyway
       
   353             }
       
   354         // event is needed in upper level for correct bubble and log handling
       
   355         ExecCbCallEventOccurred( MCCPCallObserver::ECCPRemoteTerminated );
       
   356         // idle can be sent directly without disconnecting state
       
   357         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
   358         }
       
   359     
       
   360     if ( KSVPHoldTimerExpired == aTimerId ||
       
   361          KSVPResumeTimerExpired == aTimerId )
       
   362         {
       
   363         if ( iHoldController )
       
   364             {
       
   365             SVPDEBUG1( "CSVPSessionBase::TimedOut - Hold/Resume request Expired" )
       
   366             
       
   367             iHoldController->TimedOut();
       
   368             TInt contErr = iHoldController->ContinueHoldProcessing( *iSession );
       
   369             
       
   370             if ( KSVPResumeTimerExpired == aTimerId &&
       
   371                  CMceSession::EEstablished == iSession->State() )
       
   372                 {
       
   373                 // MCE state error prevents cancelling session; go to terminating
       
   374                 SVPDEBUG1( "CSVPSessionBase::TimedOut - MCE established" )
       
   375                 HandleSessionStateChanged( *iSession );
       
   376                 SVPDEBUG1( "CSVPSessionBase::TimedOut - hold/resume done" )
       
   377                 }
       
   378             else
       
   379                 {
       
   380                 TRAPD( cancelErr, static_cast<CMceOutSession*>( iSession )->CancelL() );
       
   381                 
       
   382                 if ( cancelErr )
       
   383                     {
       
   384                     // This removes compile warnings; no need for other error 
       
   385                     // handling
       
   386                     SVPDEBUG2( "CSVPSessionBase::TimedOut - Hold/Resume, Err %i", 
       
   387                             cancelErr )
       
   388                     }
       
   389                 }
       
   390             
       
   391             SVPDEBUG2( "CSVPSessionBase::TimedOut - Hold/Resume Handled, Err %i",
       
   392                     contErr )
       
   393             }
       
   394         }
       
   395     
       
   396     if ( KSVPReferTimerExpired == aTimerId )
       
   397         {
       
   398         // Refer timeout
       
   399         SVPDEBUG1( "CSVPSessionBase::TimedOut Transfer/Refer timer expired" )
       
   400         
       
   401         if ( iTransferController )
       
   402             {
       
   403             // Inform application about the error
       
   404             ExecCbErrorOccurred( ECCPTransferFailed );
       
   405             // Terminate transfer
       
   406             iTransferController->TerminateTransfer();
       
   407 			}
       
   408         }
       
   409     
       
   410     if ( KSVPReInviteTimerExpired == aTimerId )
       
   411         {
       
   412         if ( iHoldController )
       
   413             {
       
   414             SVPDEBUG1( "CSVPSessionBase::TimedOut - ReInvite timer expired" )
       
   415             iHoldController->RetryHoldRequest( iSession );
       
   416             }
       
   417         }
       
   418 
       
   419     if ( KSVPICMPErrorTimerExpired == aTimerId )
       
   420         {
       
   421         TBool bothStreamsDisabled ( ETrue );
       
   422         TRAP_IGNORE( bothStreamsDisabled = IsBothStreamsDisabledL() );
       
   423         if ( bothStreamsDisabled )
       
   424             {
       
   425             SVPDEBUG1( "CSVPSessionBase::TimedOut Error In UL and DL \
       
   426             NOT First Time! -> Start Terminating Timer and BYE" )
       
   427             // notify CCE about the error & bring session down.
       
   428             ExecCbErrorOccurred( ECCPErrorConnectionError );
       
   429             ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
   430         
       
   431             TRAP_IGNORE( StartTimerL( KSVPTerminatingTime, KSVPRemoteEndDiedExpired ) );
       
   432             }
       
   433         else
       
   434             {
       
   435             SVPDEBUG1( "CSVPSessionBase::TimedOut UpLink or DownLink \
       
   436             is not Disabled! -> No Terminating Timer needed, all is OK!" )
       
   437             }
       
   438         SetErrorInULandDLFirstTime( ETrue );        
       
   439         }
       
   440 
       
   441     if ( KSVPSinkResumeICMPErrorTimerExpired == aTimerId ||
       
   442          KSVPSourceResumeICMPErrorTimerExpired == aTimerId )
       
   443         {
       
   444         if ( iHoldController )
       
   445             {
       
   446             // ICMP errors in resume disables RTP sink, try to enable it: 
       
   447             SVPDEBUG1( "CSVPSessionBase::TimedOut - Resume ICMP error timer expired" )
       
   448             TRAPD( refreshErr, HoldController().RefreshHoldStateL() );
       
   449             if ( refreshErr )
       
   450                 {
       
   451                 // Removes compile warnings; no other error handling
       
   452                 SVPDEBUG2( "CSVPSessionBase::TimedOut - refreshHold err %d", refreshErr )
       
   453                 }
       
   454             }
       
   455         }
       
   456 
       
   457     SVPDEBUG1( "CSVPSessionBase::TimedOut Out" )
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CSVPSessionBase::SessionStateChanged
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 void CSVPSessionBase::SessionStateChanged( TInt aStatusCode )
       
   465     {
       
   466     SVPDEBUG2( "CSVPSessionBase::SessionStateChanged  In,  aStatusCode= %d", aStatusCode )
       
   467     SVPDEBUG2( "CSVPSessionBase::SessionStateChanged iSession->State()= %d", iSession->State() )
       
   468     
       
   469     TInt status = aStatusCode;
       
   470     TCCPError err = iSVPUtility.GetCCPError( status, iTone );
       
   471     
       
   472     // On error call voip event logger with original status, 3xx are not logged.
       
   473     if ( ECCPErrorNone != err && ECCPErrorNotReached != err )
       
   474         {
       
   475         TRAP_IGNORE( iSVPUtility.LogVoipEventL( aStatusCode,
       
   476                 iSipProfileId, RemoteParty(), CSeqHeader() ) );
       
   477         }
       
   478     
       
   479     #ifdef _DEBUG   // UDEB build
       
   480     
       
   481     TRAPD( trapErr, SessionStateChangedL( aStatusCode, err, status ) );
       
   482     SVPDEBUG2( "CSVPSessionBase::SessionStateChanged trapErr: %d", trapErr )
       
   483     
       
   484     #else // UREL build
       
   485     
       
   486     TRAP_IGNORE( SessionStateChangedL( aStatusCode, err, status ) );
       
   487     
       
   488     #endif // _DEBUG
       
   489     
       
   490     SVPDEBUG1( "CSVPSessionBase::SessionStateChanged Out" )
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // CSVPSessionBase::InitializePropertyWatchingL
       
   495 // ---------------------------------------------------------------------------
       
   496 //
       
   497 void CSVPSessionBase::InitializePropertyWatchingL()
       
   498     {
       
   499     SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL In" )
       
   500     
       
   501     // create property watcher for watching mute P&S property changes
       
   502     iMutePropertyWatch = CSVPPropertyWatch::NewL(
       
   503             *this, KPSUidTelMicrophoneMuteStatus, KTelMicrophoneMuteState );
       
   504     
       
   505     // check initial mute value                                  
       
   506     TInt value( EPSTelMicMuteOff );
       
   507     RProperty::Get( KPSUidTelMicrophoneMuteStatus, 
       
   508             KTelMicrophoneMuteState, value );
       
   509     
       
   510     // check initial mute status 
       
   511     if( EPSTelMicMuteOff == value )
       
   512         {
       
   513         SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL Initally mute: OFF" )
       
   514         }
       
   515     else if ( EPSTelMicMuteOn == value )
       
   516         {
       
   517         SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL Initially Mute: ON" )
       
   518         // if mute is initially on, we must mute the audio
       
   519         ValueChangedL( KTelMicrophoneMuteState, EPSTelMicMuteOn );
       
   520         }
       
   521     
       
   522     // create instance of volume obsever
       
   523     iVolObserver = CSVPVolumeObserver::NewL( *this );
       
   524     
       
   525     SVPDEBUG1( "CSVPSessionBase::InitializePropertyWatchingL Out" )
       
   526     }
       
   527 
       
   528 // ---------------------------------------------------------------------------
       
   529 // CSVPSessionBase::ExecCbErrorOccurred
       
   530 // ---------------------------------------------------------------------------
       
   531 // 
       
   532 TInt CSVPSessionBase::ExecCbErrorOccurred( TCCPError aError )
       
   533     {
       
   534     SVPDEBUG2( "CSVPSessionBase::ExecCbErrorOccurred In, aError= %d", aError )
       
   535     
       
   536     TInt status = KErrNotFound;
       
   537     
       
   538     if ( iCCPSessionObserver )
       
   539         {
       
   540         status = KErrNone;
       
   541         iCCPSessionObserver->ErrorOccurred( aError, this );
       
   542         }
       
   543     
       
   544     SVPDEBUG2( "CSVPSessionBase::ExecCbErrorOccurred Out return=%d", status )
       
   545     return status;
       
   546     }
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // CSVPSessionBase::ExecCbCallStateChanged
       
   550 // ---------------------------------------------------------------------------
       
   551 // 
       
   552 TInt CSVPSessionBase::ExecCbCallStateChanged(
       
   553         MCCPCallObserver::TCCPCallState aNewState )
       
   554     {
       
   555     SVPDEBUG2( "CSVPSessionBase::ExecCbCallStateChanged In, aNewState= %d", aNewState )
       
   556     SVPDEBUG2( "CSVPSessionBase::ExecCbCallStateChanged iSessionState= %d", iSessionState )
       
   557     
       
   558     TInt status = (TInt) aNewState;
       
   559     
       
   560     if ( !( (TInt) MCCPCallObserver::ECCPStateIdle > status ) )
       
   561         {
       
   562         // state transition OK
       
   563         iSessionState = (MCCPCallObserver::TCCPCallState) status;
       
   564         
       
   565         if ( iCCPSessionObserver )
       
   566             {
       
   567             status = KErrNone;
       
   568             iCCPSessionObserver->CallStateChanged( iSessionState, this );
       
   569             }
       
   570         }
       
   571     
       
   572     SVPDEBUG2( "CSVPSessionBase::ExecCbCallStateChanged Out return=%d", status )
       
   573     return status;
       
   574     }
       
   575 
       
   576 // ---------------------------------------------------------------------------
       
   577 // CSVPSessionBase::ExecCbCallEventOccurred
       
   578 // ---------------------------------------------------------------------------
       
   579 //
       
   580 TInt CSVPSessionBase::ExecCbCallEventOccurred(
       
   581         MCCPCallObserver::TCCPCallEvent aEvent )
       
   582     {
       
   583     SVPDEBUG2( "CSVPSessionBase::ExecCbCallEventOccurred In, aEvent= %d", aEvent )
       
   584     
       
   585     TInt status = KErrNotFound;
       
   586     
       
   587     if ( iCCPSessionObserver )
       
   588         {
       
   589         status = KErrNone;
       
   590         iCCPSessionObserver->CallEventOccurred( aEvent, this );
       
   591         }
       
   592     
       
   593     SVPDEBUG2( "CSVPSessionBase::ExecCbCallEventOccurred Out, return= %d", status )
       
   594     return status;
       
   595     }
       
   596 
       
   597 // ---------------------------------------------------------------------------
       
   598 // CSVPSessionBase::ExecCbSsEventOccurred
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 TInt CSVPSessionBase::ExecCbSsEventOccurred(
       
   602         MCCPSsObserver::TCCPSsCallForwardEvent aEvent )
       
   603     {
       
   604     SVPDEBUG2( "CSVPSessionBase::ExecCbSsEventOccurred In, aEvent= %d", aEvent )
       
   605     
       
   606     TInt status = KErrNotFound;
       
   607     
       
   608     if ( iCCPSsObserver )
       
   609         {
       
   610         status = KErrNone;
       
   611         iCCPSsObserver->CallForwardEventOccurred( aEvent, *iRecipient );
       
   612         }
       
   613     
       
   614     SVPDEBUG2( "CSVPSessionBase::ExecCbSsEventOccurred Out return=%d", status )
       
   615     return status;
       
   616     }
       
   617 
       
   618 
       
   619 //----------------------------------------------------------------------------
       
   620 //CSVPSessionBase::SetSsObserver
       
   621 //----------------------------------------------------------------------------
       
   622 //
       
   623 void CSVPSessionBase::SetSsObserver( const MCCPSsObserver& aObserver )
       
   624     {
       
   625     SVPDEBUG1( "CSVPSessionBase::SetSsObserver In" )
       
   626     
       
   627     iCCPSsObserver = const_cast< MCCPSsObserver* >( &aObserver );
       
   628     
       
   629     SVPDEBUG1( "CSVPSessionBase::SetSsObserver In" )
       
   630     }
       
   631 
       
   632 //----------------------------------------------------------------------------
       
   633 //CSVPSessionBase::GetSsObserver
       
   634 //----------------------------------------------------------------------------
       
   635 //
       
   636 const MCCPSsObserver& CSVPSessionBase::GetSsObserver( )
       
   637     {
       
   638     SVPDEBUG1( "CSVPSessionBase::GetSsObserver" )
       
   639     
       
   640     return *iCCPSsObserver;    
       
   641     }
       
   642 
       
   643 // ---------------------------------------------------------------------------
       
   644 // CSVPSessionBase::SetDtmfObserver
       
   645 // ---------------------------------------------------------------------------
       
   646 //
       
   647 void CSVPSessionBase::SetDtmfObserver( const MCCPDTMFObserver& aObserver )
       
   648     {
       
   649     SVPDEBUG1( "CSVPSessionBase::SetDtmfObserver In" )
       
   650     
       
   651     iCCPDtmfObserver = const_cast< MCCPDTMFObserver* >( &aObserver );
       
   652     
       
   653     SVPDEBUG1( "CSVPSessionBase::SetDtmfObserver Out" )
       
   654     }
       
   655 
       
   656 // ---------------------------------------------------------------------------
       
   657 // CSVPSessionBase::DtmfObserver
       
   658 // ---------------------------------------------------------------------------
       
   659 //
       
   660 const MCCPDTMFObserver& CSVPSessionBase::DtmfObserver()
       
   661     {
       
   662     SVPDEBUG1( "CSVPSessionBase::DtmfObserver" )
       
   663     
       
   664     return *iCCPDtmfObserver;
       
   665     }
       
   666 
       
   667 // ---------------------------------------------------------------------------
       
   668 // CSVPSessionBase::EventStateChanged
       
   669 // ---------------------------------------------------------------------------
       
   670 //
       
   671 TInt CSVPSessionBase::EventStateChanged( CMceEvent& aEvent, TInt aStatusCode )
       
   672     {
       
   673     SVPDEBUG1( "CSVPSessionBase::EventStateChanged In" )
       
   674     
       
   675     TInt err( KErrNone );
       
   676     
       
   677     if ( iTransferController )
       
   678         {
       
   679         TRAP( err, iTransferController->HandleEventStateChangedL(
       
   680                 aEvent, aStatusCode ) );
       
   681         
       
   682         if ( KSVPErrTransferInProgress == err )
       
   683             {
       
   684             // Transfer allready in progress
       
   685             SVPDEBUG1( "CSVPSessionBase::EventStateChanged, KSVPErrTransferInProgress" )
       
   686             }
       
   687         else if ( KErrNone != err )
       
   688             {
       
   689             SVPDEBUG2( "CSVPSessionBase::EventStateChanged, err = %d", err )
       
   690             // Inform application about the error
       
   691             ExecCbErrorOccurred( ECCPTransferFailed );
       
   692             }
       
   693         }
       
   694     else
       
   695         {
       
   696         // Inform application about the error
       
   697         ExecCbErrorOccurred( ECCPTransferFailed );
       
   698         err = KSVPErrTransferErrorBase;
       
   699         }
       
   700     
       
   701     SVPDEBUG2( "CSVPSessionBase::EventStateChanged Out return=%d", err )
       
   702     return err;
       
   703     }
       
   704 
       
   705 // ---------------------------------------------------------------------------
       
   706 // CSVPSessionBase::NotifyReceived
       
   707 // ---------------------------------------------------------------------------
       
   708 //
       
   709 void CSVPSessionBase::NotifyReceived( CMceEvent& aEvent,
       
   710         TMceTransactionDataContainer* aContainer )
       
   711     {
       
   712     SVPDEBUG1( "CSVPSessionBase::NotifyReceived In" )
       
   713     
       
   714     if ( iTransferController )
       
   715         {
       
   716         TRAPD( err, iTransferController->NotifyReceivedL(
       
   717                 aEvent, aContainer ) );
       
   718         
       
   719         if ( KErrNone != err )
       
   720             {
       
   721             // Inform application about the error
       
   722             ExecCbErrorOccurred( ECCPTransferFailed );
       
   723             }
       
   724         }
       
   725     else
       
   726         {
       
   727         // Inform application about the error
       
   728         ExecCbErrorOccurred( ECCPTransferFailed );
       
   729         }
       
   730     
       
   731     SVPDEBUG1( "CSVPSessionBase::NotifyReceived Out" )
       
   732     }
       
   733 
       
   734 // ---------------------------------------------------------------------------
       
   735 // CSVPSessionBase::ReferStateChanged
       
   736 // ---------------------------------------------------------------------------
       
   737 // 
       
   738 void CSVPSessionBase::ReferStateChanged( CMceRefer& aRefer, TInt aStatusCode )
       
   739     {
       
   740     SVPDEBUG1( "CSVPSessionBase::ReferStateChangedL In" )
       
   741     
       
   742     if ( iTransferController )
       
   743         {
       
   744         TRAPD( err, iTransferController->HandleReferStateChangeL(
       
   745                 aRefer, aStatusCode ) );
       
   746         
       
   747         if ( KErrNone != err )
       
   748             {
       
   749             // Inform application about the error
       
   750             ExecCbErrorOccurred( ECCPTransferFailed );
       
   751             }
       
   752         }
       
   753     else
       
   754         {
       
   755         // Inform application about the error
       
   756         ExecCbErrorOccurred( ECCPTransferFailed );
       
   757         }
       
   758     
       
   759     SVPDEBUG1( "CSVPSessionBase::ReferStateChangedL Out" )
       
   760     }
       
   761 
       
   762 // ---------------------------------------------------------------------------
       
   763 // CSVPSessionBase::MceTransactionDataContainer
       
   764 // ---------------------------------------------------------------------------
       
   765 //
       
   766 TMceTransactionDataContainer& CSVPSessionBase::MceTransactionDataContainer()
       
   767     {
       
   768     return iContainer;
       
   769     }
       
   770 
       
   771 // ---------------------------------------------------------------------------
       
   772 // CSVPSessionBase::IncomingReferL
       
   773 // ---------------------------------------------------------------------------
       
   774 //
       
   775 void CSVPSessionBase::IncomingReferL( CMceInRefer* aRefer,
       
   776         const TDesC8& aReferTo, TMceTransactionDataContainer* aContainer )
       
   777     {
       
   778     SVPDEBUG1( "CSVPSessionBase::IncomingReferL In" )
       
   779     
       
   780     if ( !iTransferController )        
       
   781         {
       
   782         // Create new transfercontroller
       
   783         iTransferController = CSVPTransferController::NewL(
       
   784                 iSession, this, iContainer, *this );
       
   785         }
       
   786     
       
   787     iTransferController->IncomingReferL( aRefer, aReferTo, aContainer );
       
   788     
       
   789     SVPDEBUG1( "CSVPSessionBase::IncomingReferL Out" )    
       
   790     }
       
   791 
       
   792 // ---------------------------------------------------------------------------
       
   793 // CSVPSessionBase::IsMceRefer
       
   794 // ---------------------------------------------------------------------------
       
   795 //
       
   796 TBool CSVPSessionBase::IsMceRefer( CMceRefer& aRefer )
       
   797     {
       
   798     if ( iTransferController )
       
   799         {
       
   800         return iTransferController->IsMceRefer( aRefer );        
       
   801         }
       
   802     else
       
   803         {
       
   804         return EFalse;    
       
   805         }   
       
   806     }
       
   807 
       
   808 // ---------------------------------------------------------------------------
       
   809 // CSVPSessionBase::IsAttended
       
   810 // ---------------------------------------------------------------------------
       
   811 //
       
   812 TBool CSVPSessionBase::IsAttended()
       
   813     {
       
   814     if ( iTransferController )
       
   815         {
       
   816         return iTransferController->IsAttended();
       
   817         }
       
   818     else
       
   819         {
       
   820         return EFalse;
       
   821         }
       
   822     }
       
   823 
       
   824 // ---------------------------------------------------------------------------
       
   825 // CSVPSessionBase::SetTransferDataL
       
   826 // ---------------------------------------------------------------------------
       
   827 //
       
   828 void CSVPSessionBase::SetTransferDataL( CDesC8Array* aUserAgentHeaders,
       
   829         TInt aSecureStatus )
       
   830     {
       
   831     SVPDEBUG1( "CSVPSessionBase::SetTransferDataL In" )
       
   832     
       
   833     if ( iTransferController )
       
   834         {
       
   835         iTransferController->SetTransferDataL(
       
   836             aUserAgentHeaders, aSecureStatus );
       
   837         }
       
   838     
       
   839     SVPDEBUG1( "CSVPSessionBase::SetTransferDataL Out" )
       
   840     }
       
   841 
       
   842 // ---------------------------------------------------------------------------
       
   843 // CSVPSessionBase::SendNotify
       
   844 // ---------------------------------------------------------------------------
       
   845 //
       
   846 void CSVPSessionBase::SendNotify( TInt aStatusCode )
       
   847     {
       
   848     SVPDEBUG1( "CSVPSessionBase::SendNotify In" )
       
   849     
       
   850     if ( iTransferController )
       
   851         {
       
   852         #ifdef _DEBUG
       
   853         
       
   854         TRAPD( err, iTransferController->SendNotifyL( aStatusCode ) );
       
   855         SVPDEBUG2("CSVPSessionBase::SendNotify SendNotifyL err: %d", err )
       
   856         
       
   857         #else
       
   858         
       
   859         TRAP_IGNORE( iTransferController->SendNotifyL( aStatusCode ) );
       
   860         
       
   861         #endif // _DEBUG
       
   862         }
       
   863     
       
   864     SVPDEBUG1( "CSVPSessionBase::SendNotify Out" )
       
   865     }
       
   866 
       
   867 // ---------------------------------------------------------------------------
       
   868 // CSVPSessionBase::IsIncomingTransfer
       
   869 // ---------------------------------------------------------------------------
       
   870 //
       
   871 TBool CSVPSessionBase::IsIncomingTransfer()
       
   872     {
       
   873     if ( iTransferController )
       
   874         {
       
   875         return iTransferController->IsIncomingTransfer();
       
   876         }
       
   877     else
       
   878         {
       
   879         return EFalse;
       
   880         }
       
   881     }
       
   882 
       
   883 // ---------------------------------------------------------------------------
       
   884 // CSVPSessionBase::TransferTarget
       
   885 // ---------------------------------------------------------------------------
       
   886 //
       
   887 const TDesC& CSVPSessionBase::TransferTarget() const
       
   888     {
       
   889     SVPDEBUG1( "CSVPSessionBase::TransferTarget" )
       
   890     
       
   891     if ( iTransferController )
       
   892         {
       
   893         return iTransferController->TransferTarget();
       
   894         }
       
   895     else
       
   896         {
       
   897         return KNullDesC;
       
   898         }
       
   899     }
       
   900 
       
   901 // -----------------------------------------------------------------------------
       
   902 // CSVPSessionBase::SetFromHeader
       
   903 // -----------------------------------------------------------------------------
       
   904 //
       
   905 TInt CSVPSessionBase::SetFromHeader( const TDesC8& aFromHeader )
       
   906     {
       
   907     SVPDEBUG1( "CSVPSessionBase::SetFromHeader" )
       
   908     
       
   909     delete iFromHeader;
       
   910     iFromHeader = NULL;
       
   911     
       
   912     TRAPD( err, iFromHeader = aFromHeader.AllocL() );
       
   913     return err;
       
   914     }
       
   915 
       
   916 // -----------------------------------------------------------------------------
       
   917 // CSVPSessionBase::FromHeader
       
   918 // -----------------------------------------------------------------------------
       
   919 //
       
   920 TDesC8* CSVPSessionBase::FromHeader()
       
   921     {
       
   922     return iFromHeader;
       
   923     }  
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 // CSVPSessionBase::SetToHeader
       
   927 // -----------------------------------------------------------------------------
       
   928 //
       
   929 TInt CSVPSessionBase::SetToHeader( const TDesC8& aToHeader )
       
   930     {
       
   931     SVPDEBUG1( "CSVPSessionBase::SetToHeader" )
       
   932     
       
   933     delete iToHeader;
       
   934     iToHeader = NULL;
       
   935     
       
   936     TRAPD( err, iToHeader = aToHeader.AllocL() );
       
   937     return err;
       
   938     }
       
   939 
       
   940 // -----------------------------------------------------------------------------
       
   941 // CSVPSessionBase::ToHeader
       
   942 // -----------------------------------------------------------------------------
       
   943 //
       
   944 TDesC8* CSVPSessionBase::ToHeader()
       
   945     {
       
   946     return iToHeader;
       
   947     }
       
   948 
       
   949 // -----------------------------------------------------------------------------
       
   950 // CSVPSessionBase::SetCallId
       
   951 // -----------------------------------------------------------------------------
       
   952 //
       
   953 TInt CSVPSessionBase::SetCallId( const TDesC8& aCallId )
       
   954     {
       
   955     SVPDEBUG1( "CSVPSessionBase::SetCallId" )
       
   956     
       
   957     delete iCallId;
       
   958     iCallId = NULL;
       
   959     
       
   960     TRAPD( err, iCallId = aCallId.AllocL() );
       
   961     return err;
       
   962     }
       
   963 
       
   964 // -----------------------------------------------------------------------------
       
   965 // CSVPSessionBase::CallId
       
   966 // -----------------------------------------------------------------------------
       
   967 //
       
   968 TDesC8* CSVPSessionBase::CallId()
       
   969     {
       
   970     return iCallId;
       
   971     }
       
   972 
       
   973 // -----------------------------------------------------------------------------
       
   974 // CSVPSessionBase::SetCSeqHeader
       
   975 // -----------------------------------------------------------------------------
       
   976 //
       
   977 TInt CSVPSessionBase::SetCSeqHeader( const TDesC8& aCSeq )
       
   978     {
       
   979     SVPDEBUG1( "CSVPSessionBase::SetCSeqHeader In" )
       
   980     
       
   981     delete iCSeqHeader;
       
   982     iCSeqHeader = NULL;
       
   983     
       
   984     TRAPD( err, iCSeqHeader = HBufC::NewL( aCSeq.Length() ) );
       
   985     iCSeqHeader->Des().Copy( aCSeq );
       
   986     
       
   987     // Check "CSeq:" and remove it from the beginning if exists
       
   988     if ( 0 == iCSeqHeader->Des().FindF( KSVPCSeqPrefix ) )
       
   989         {
       
   990         // CSeq: is in the beginning of the string, remove it and 1 blank
       
   991         iCSeqHeader->Des().Delete( 0, KSVPCSeqPrefixLength + 1 );
       
   992         }
       
   993     
       
   994     // Check/remove the sequence number and the blank
       
   995     const TInt spacePosition = iCSeqHeader->Des().Find( KSVPSpace2 );
       
   996     
       
   997     if ( spacePosition != KErrNotFound )
       
   998         {
       
   999         iCSeqHeader->Des().Delete( 0, spacePosition + 1 );
       
  1000         }
       
  1001     
       
  1002     SVPDEBUG2( "CSVPSessionBase::SetCSeqHeader Out return=%d", err )
       
  1003     return err;
       
  1004     }
       
  1005 
       
  1006 // ---------------------------------------------------------------------------
       
  1007 // CSVPSessionBase::CSeqHeader
       
  1008 // ---------------------------------------------------------------------------
       
  1009 // 
       
  1010 const TDesC& CSVPSessionBase::CSeqHeader() const
       
  1011     {
       
  1012     SVPDEBUG1( "CSVPSessionBase::CSeqHeader In" )  
       
  1013     
       
  1014     if ( iCSeqHeader )
       
  1015         {
       
  1016         SVPDEBUG1( "CSVPSessionBase::CSeqHeader Out" )
       
  1017         return *iCSeqHeader;
       
  1018         }
       
  1019     else
       
  1020         {
       
  1021         SVPDEBUG1( "CSVPSessionBase::CSeqHeader Out KNullDesC" )
       
  1022         return KNullDesC;
       
  1023         }
       
  1024     }
       
  1025 
       
  1026 // ---------------------------------------------------------------------------
       
  1027 // CSVPSessionBase::AddObserverL
       
  1028 // ---------------------------------------------------------------------------
       
  1029 //
       
  1030 void CSVPSessionBase::AddObserverL( const MCCPCallObserver& aObserver )
       
  1031     {
       
  1032     SVPDEBUG1( "CSVPSessionBase::AddObserverL In" )
       
  1033     
       
  1034     // set session observer
       
  1035     // only one observer used at a time, replaces current one
       
  1036     iCCPSessionObserver = const_cast< MCCPCallObserver* >( &aObserver );
       
  1037     
       
  1038     SVPDEBUG1( "CSVPSessionBase::AddObserverL Out" )
       
  1039     }
       
  1040 
       
  1041 // ---------------------------------------------------------------------------
       
  1042 // CSVPSessionBase::GetCCPSessionObserver
       
  1043 // ---------------------------------------------------------------------------
       
  1044 //
       
  1045 MCCPCallObserver& CSVPSessionBase::GetCCPSessionObserver()
       
  1046     {
       
  1047     SVPDEBUG1( "CSVPSessionBase::GetCCPSessionObserver" )
       
  1048     // get session observer
       
  1049     return *iCCPSessionObserver;
       
  1050     }
       
  1051 
       
  1052 // ---------------------------------------------------------------------------
       
  1053 // CSVPSessionBase::RemoveObserver
       
  1054 // ---------------------------------------------------------------------------
       
  1055 //
       
  1056 TInt CSVPSessionBase::RemoveObserver( const MCCPCallObserver& /*aObserver*/ )
       
  1057     {
       
  1058     return KErrNotSupported; 
       
  1059     }
       
  1060 
       
  1061 // ---------------------------------------------------------------------------
       
  1062 // CSVPSessionBase::InbandDtmfEventOccurred
       
  1063 // ---------------------------------------------------------------------------
       
  1064 //
       
  1065 void CSVPSessionBase::InbandDtmfEventOccurred( TSVPDtmfEvent aEvent )
       
  1066     {
       
  1067     SVPDEBUG1( "CSVPSessionBase::InbandDtmfEventOccurred In" )
       
  1068     SVPDEBUG2( "CSVPSessionBase::InbandDtmfEventOccurred aEvent:%d", aEvent )
       
  1069       
       
  1070     switch ( aEvent )
       
  1071         {
       
  1072         case ESvpDtmfSendStarted:
       
  1073             {
       
  1074             DtmfObserver().
       
  1075                 HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfSequenceStart, 
       
  1076                                  KErrNone, 
       
  1077                                  iDtmfLex.Peek() );
       
  1078             break;
       
  1079             }
       
  1080             
       
  1081         case ESvpDtmfSendStopped:
       
  1082             {
       
  1083             DtmfObserver().HandleDTMFEvent( 
       
  1084                                  MCCPDTMFObserver::ECCPDtmfSequenceStop, 
       
  1085                                  KErrNone, 
       
  1086                                  iDtmfLex.Get() );
       
  1087             break;
       
  1088             }
       
  1089             
       
  1090         case ESvpDtmfSendCompleted:
       
  1091             {
       
  1092             DtmfObserver().HandleDTMFEvent( 
       
  1093                      MCCPDTMFObserver::ECCPDtmfStringSendingCompleted, 
       
  1094                      KErrNone, 
       
  1095                      iDtmfLex.Peek() );
       
  1096             break;
       
  1097             }
       
  1098         
       
  1099         default:
       
  1100             {
       
  1101             SVPDEBUG1( "CSVPSessionBase::InbandDtmfEventOccurred Default" )
       
  1102             break;
       
  1103             }
       
  1104         }
       
  1105     
       
  1106     SVPDEBUG1( "CSVPSessionBase::InbandDtmfEventOccurred Out" )
       
  1107     }
       
  1108 
       
  1109   
       
  1110 // ---------------------------------------------------------------------------
       
  1111 // CSVPSessionBase::ConstructAudioStreamsL
       
  1112 // ---------------------------------------------------------------------------
       
  1113 //
       
  1114 void CSVPSessionBase::ConstructAudioStreamsL()
       
  1115     {
       
  1116     SVPDEBUG1( "CSVPSessionBase::ConstructAudioStreamsL In" )
       
  1117     
       
  1118     // OUT STREAM
       
  1119     // create "audio out" stream first, puts audioOutStream to cleanupstack
       
  1120     CMceAudioStream* audioOutStream = CMceAudioStream::NewLC();     // CS: 1
       
  1121     // create mic source
       
  1122     CMceMicSource* mic = CMceMicSource::NewLC();                    // CS: 2
       
  1123     // set source for "audio out" stream, in this case it's microphone
       
  1124     // there can be only one source at a time.
       
  1125     audioOutStream->SetSourceL( mic );
       
  1126     // pop mic from cleanupstack
       
  1127     CleanupStack::Pop( mic );                                       // CS: 1
       
  1128     // create rtp sink for mic
       
  1129     CMceRtpSink* rtpSink = CMceRtpSink::NewLC();                    // CS: 2
       
  1130     audioOutStream->AddSinkL( rtpSink );
       
  1131     CleanupStack::Pop( rtpSink );                                   // CS: 1
       
  1132     
       
  1133     // IN STREAM
       
  1134     // create "audio in" stream
       
  1135     CMceAudioStream* audioInStream = CMceAudioStream::NewLC();      // CS: 2
       
  1136     // create rtp source for "audio in" stream
       
  1137     CMceRtpSource* rtpSource = CMceRtpSource::NewLC(
       
  1138             KSvpJitterBufferLength, KSvpJitterBufferThreshold, 
       
  1139             KSvpStandbyTimerInMillisecs );                          // CS: 3
       
  1140     audioInStream->SetSourceL( rtpSource );
       
  1141     // pop rtp source from cleanupstack
       
  1142     CleanupStack::Pop( rtpSource );                                 // CS: 2
       
  1143     // create speaker sink for "audio in" stream
       
  1144     CMceSpeakerSink* speakerSink = CMceSpeakerSink::NewLC();        // CS: 3
       
  1145     audioInStream->AddSinkL( speakerSink );
       
  1146     // pop speaker from cleanupstack
       
  1147     CleanupStack::Pop( speakerSink );                               // CS: 2
       
  1148     
       
  1149     // Bind "audio out" stream to "audio in" stream. Ownership of the stream
       
  1150     // is transferred thus we must pop the instream from CS.
       
  1151     audioOutStream->BindL( audioInStream );
       
  1152     CleanupStack::Pop( audioInStream );                             // CS: 1
       
  1153     
       
  1154     // Add stream to session. Note that the ownership is transferred thus
       
  1155     // we pop the audioOutStream in this phase.
       
  1156     iSession->AddStreamL( audioOutStream );
       
  1157     CleanupStack::Pop( audioOutStream );                            // CS: 0
       
  1158     
       
  1159     // establish Old way hold support 
       
  1160     iSession->SetModifierL( KMceMediaDirection,
       
  1161             KMceMediaDirectionWithAddress );
       
  1162     
       
  1163     // preconditions are set so that long negotiation is taken in to use
       
  1164     // when establishing secure call
       
  1165     if ( SecureMandatory() || SecurePreferred() )
       
  1166         {
       
  1167         iSession->SetModifierL( KMceSecPreconditions, 
       
  1168                                 KMcePreconditionsE2ESupported );
       
  1169         }
       
  1170     else
       
  1171         {
       
  1172         // else modify preconditions off
       
  1173         iSession->SetModifierL( KMcePreconditions, 
       
  1174                                 KMcePreconditionsNotUsed );
       
  1175         }
       
  1176     
       
  1177     SVPDEBUG2( "CSVPSessionBase::ConstructAudioStreamsL audioInStream codec count: %d",
       
  1178             audioInStream->Codecs().Count() )
       
  1179     SVPDEBUG2( "CSVPSessionBase::ConstructAudioStreamsL audioOutStream codec count: %d",
       
  1180             audioOutStream->Codecs().Count() )
       
  1181     
       
  1182     // add codecs to audiostream
       
  1183     iSVPUtility.SetAudioCodecsMOL(
       
  1184             iVoIPProfileId, *audioInStream, iKeepAliveValue );
       
  1185 
       
  1186     // set same local media port from InStream to OutStream 
       
  1187     audioOutStream->SetLocalMediaPortL( audioInStream->LocalMediaPort() );
       
  1188     iSVPUtility.UpdateJitterBufferSizeL( *rtpSource );
       
  1189     
       
  1190     // set MMF priorities and preferences to codecs
       
  1191     SVPDEBUG1( "CSVPSessionBase::ConstructAudioStreamsL Set MMF priorities" )
       
  1192     iSVPUtility.SetDtmfMode( SVPAudioUtility::SetPriorityCodecValuesL(
       
  1193             *audioInStream, *audioOutStream ) );
       
  1194     
       
  1195     SVPDEBUG1( "CSVPSessionBase::ConstructAudioStreamsL Out" )
       
  1196     }
       
  1197 
       
  1198 // ---------------------------------------------------------------------------
       
  1199 // CSVPSessionBase::HangUp
       
  1200 // ---------------------------------------------------------------------------
       
  1201 //
       
  1202 TInt CSVPSessionBase::HangUp()
       
  1203     {
       
  1204     SVPDEBUG1( "CSVPSessionBase::HangUp In" )
       
  1205     
       
  1206     TInt err( KErrNone );
       
  1207     
       
  1208     if ( CMceSession::EEstablished == iSession->State() )
       
  1209         {
       
  1210         SVPDEBUG1( "CSVPSessionBase::HangUp() TerminateL" )
       
  1211         
       
  1212         TRAP( err, iSession->TerminateL() );
       
  1213         
       
  1214         if ( !err )
       
  1215             {
       
  1216             ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
  1217             
       
  1218 	        // IsAttended() and different timer values needed for 
       
  1219             // attended transfer when there is also one waiting call queued
       
  1220             // and ringing tone for queued session needs to be played
       
  1221             TInt timerID = 0;
       
  1222             TInt delay = 0;
       
  1223             
       
  1224             if ( IsAttended() )
       
  1225             	{
       
  1226 	            delay = KSVPTerminatingTime;
       
  1227 	            timerID = KSVPTerminationTimerExpired;
       
  1228             	}
       
  1229             else{
       
  1230 	            delay = KSVPMoHangupTerminatingTime;
       
  1231 	            timerID = KSVPHangUpTimerExpired;
       
  1232             	}
       
  1233             
       
  1234             TRAPD( errTimer, StartTimerL( delay, timerID ) );
       
  1235             
       
  1236             if ( errTimer )
       
  1237                 {
       
  1238                 SVPDEBUG2("CSVPSessionBase::HangUp timer leave with error code %d",
       
  1239                         errTimer )
       
  1240                 }
       
  1241             else
       
  1242             	{
       
  1243             	iAlreadyTerminating = ETrue;
       
  1244             	}
       
  1245             }   
       
  1246         }
       
  1247     else
       
  1248         {
       
  1249         SVPDEBUG2( "CSVPSessionBase::HangUp() Wrong state: %d", iSession->State() )
       
  1250         
       
  1251         StopTimers();
       
  1252         ExecCbCallStateChanged( MCCPCallObserver::ECCPStateIdle );
       
  1253         }
       
  1254     
       
  1255     SVPDEBUG2( "CSVPSessionBase::HangUp Out return=%d", err )
       
  1256     return err;
       
  1257     }
       
  1258 
       
  1259 // ---------------------------------------------------------------------------
       
  1260 // CSVPSessionBase::Hold
       
  1261 // ---------------------------------------------------------------------------
       
  1262 //
       
  1263 TInt CSVPSessionBase::Hold()
       
  1264     {
       
  1265     SVPDEBUG1( "CSVPSessionBase::Hold In" )
       
  1266     
       
  1267     TInt err( KErrNone );
       
  1268     
       
  1269     if ( CMceSession::EEstablished == iSession->State() )
       
  1270         {
       
  1271         if ( !iHoldController )
       
  1272             {
       
  1273             TRAP( err, iHoldController = 
       
  1274                     CSVPHoldController::NewL( *iSession, 
       
  1275                                               iContainer, 
       
  1276                                               this,
       
  1277                                               IsMobileOriginated() ) );
       
  1278             if ( KErrNone != err )
       
  1279                 {
       
  1280                 return err;
       
  1281                 }
       
  1282             }
       
  1283         
       
  1284         iHoldController->Muted( iMuted );
       
  1285         err = iHoldController->HoldSession( iSession );
       
  1286         
       
  1287         if ( KErrNone != err )
       
  1288             {
       
  1289             ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1290             }
       
  1291         else
       
  1292             {
       
  1293             TRAP( err, StartTimerL( KSVPHoldExpirationTime,
       
  1294                     KSVPHoldTimerExpired ) );
       
  1295             
       
  1296             SVPDEBUG2( "CSVPSessionBase::Hold - Started Expire timer, err %i",
       
  1297                        err )
       
  1298             }
       
  1299         }
       
  1300     
       
  1301     else
       
  1302         {
       
  1303         ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1304         }
       
  1305     
       
  1306     SVPDEBUG2( "CSVPSessionBase::Hold Out return=%d", err )
       
  1307     return err;
       
  1308     }
       
  1309 
       
  1310 // ---------------------------------------------------------------------------
       
  1311 // CSVPSessionBase::Resume
       
  1312 // ---------------------------------------------------------------------------
       
  1313 //
       
  1314 TInt CSVPSessionBase::Resume()
       
  1315     {
       
  1316     SVPDEBUG1( "CSVPSessionBase::Resume In" )
       
  1317     
       
  1318     TInt err( KErrNone );
       
  1319     
       
  1320     if ( !iHoldController )
       
  1321         {
       
  1322         TRAP( err, iHoldController = CSVPHoldController::NewL(
       
  1323                 *iSession, iContainer, this, IsMobileOriginated() ) );
       
  1324         
       
  1325         if ( KErrNone != err )
       
  1326             {
       
  1327             SVPDEBUG2( "CSVPSessionBase::Resume Out return(err)=%d", err )
       
  1328             return err;
       
  1329             }
       
  1330         }
       
  1331     
       
  1332     iHoldController->Muted( iMuted );  
       
  1333     err = iHoldController->ResumeSession( iSession );
       
  1334     
       
  1335     if ( KErrNone != err )
       
  1336         {
       
  1337         ExecCbErrorOccurred( ECCPLocalResumeFail );
       
  1338         }
       
  1339     else
       
  1340         {
       
  1341         TRAP( err, StartTimerL( KSVPResumeExpirationTime,
       
  1342                 KSVPResumeTimerExpired ) );
       
  1343         SVPDEBUG2("CSVPSessionBase::Resume - Started Expire timer, err %i",
       
  1344                    err );
       
  1345         }
       
  1346         
       
  1347     SVPDEBUG2( "CSVPSessionBase::Resume Out return=%d", err )
       
  1348     return err;  
       
  1349     }
       
  1350         
       
  1351 // ---------------------------------------------------------------------------
       
  1352 // CSVPSessionBase::IncomingRequest
       
  1353 // ---------------------------------------------------------------------------
       
  1354 //
       
  1355 TInt CSVPSessionBase::IncomingRequest( CMceInSession& aUpdatedSession )
       
  1356     {
       
  1357     SVPDEBUG1( "CSVPSessionBase::IncomingRequest In" )
       
  1358 
       
  1359     // Check if own request is ongoing
       
  1360     if ( iHoldController )
       
  1361         {
       
  1362         iHoldController->CheckCrossOver( *this );
       
  1363         }
       
  1364     
       
  1365     if ( &aUpdatedSession )
       
  1366         {
       
  1367         //Because there is an update we have to discard everything about ICMP -3
       
  1368         StopTimer ( KSVPICMPErrorTimerExpired );
       
  1369         if ( !IsErrorInULandDLFirstTime() )
       
  1370             {
       
  1371             SetErrorInULandDLFirstTime( ETrue );
       
  1372             }
       
  1373         
       
  1374         TInt err( KErrNone );
       
  1375         
       
  1376         if ( !iHoldController )
       
  1377             {
       
  1378             TRAP( err, iHoldController = CSVPHoldController::NewL(
       
  1379                     *iSession, iContainer, this, IsMobileOriginated() ) );
       
  1380             
       
  1381             if ( KErrNone != err )
       
  1382                 {
       
  1383                 return err;
       
  1384                 }
       
  1385             
       
  1386             TBool sessionUpdateOngoing = ETrue;
       
  1387             
       
  1388             // Most likely a hold case, MT needs to set the keepalive
       
  1389             TRAP_IGNORE( SetRtpKeepAliveL( &aUpdatedSession,
       
  1390                     sessionUpdateOngoing ) );
       
  1391             }
       
  1392         
       
  1393         SVPDEBUG2( "CSVPSessionBase::IncomingRequest iSession: 0x%x", iSession )
       
  1394         
       
  1395         // Update changed session to the transfercontroller
       
  1396         if ( iTransferController )
       
  1397             {
       
  1398             iTransferController->SetMceSessionObject( &aUpdatedSession );
       
  1399             }
       
  1400         
       
  1401         iHoldController->Muted( iMuted );
       
  1402         
       
  1403         TInt status = iHoldController->IncomingRequest( &aUpdatedSession );
       
  1404         SVPDEBUG2( "CSVPSessionBase::IncomingRequest Out return=%d", status )
       
  1405         return status;
       
  1406         }
       
  1407     else
       
  1408         {
       
  1409         SVPDEBUG1( "CSVPSessionBase::IncomingRequest Out illegal aUpdatedSession" )
       
  1410         return KErrArgument;
       
  1411         }
       
  1412     }
       
  1413 
       
  1414 // ---------------------------------------------------------------------------
       
  1415 // CSVPSessionBase::HoldController
       
  1416 // ---------------------------------------------------------------------------
       
  1417 //    
       
  1418 CSVPHoldController& CSVPSessionBase::HoldController() const
       
  1419     {
       
  1420     return *iHoldController;
       
  1421     }
       
  1422     
       
  1423 // ---------------------------------------------------------------------------
       
  1424 // CSVPSessionBase::HasHoldController
       
  1425 // ---------------------------------------------------------------------------
       
  1426 //
       
  1427 TBool CSVPSessionBase::HasHoldController() const
       
  1428     {
       
  1429     if ( iHoldController )
       
  1430         {
       
  1431         return ETrue;
       
  1432         }
       
  1433     else
       
  1434         {
       
  1435         return EFalse;
       
  1436         }
       
  1437     }
       
  1438     
       
  1439 // ---------------------------------------------------------------------------
       
  1440 // CSVPSessionBase::HandleSessionStateChanged
       
  1441 // ---------------------------------------------------------------------------
       
  1442 //
       
  1443 void CSVPSessionBase::HandleSessionStateChanged( CMceSession& aSession )
       
  1444     {
       
  1445     SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged In" )
       
  1446     
       
  1447 
       
  1448     if ( iHoldController )
       
  1449         {
       
  1450         if ( iHoldController->HoldInProgress() )
       
  1451             {
       
  1452             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged HoldInProgress" )
       
  1453             
       
  1454             StopTimers();
       
  1455             iHoldController->Muted( iMuted );
       
  1456             TInt err = iHoldController->ContinueHoldProcessing( aSession );
       
  1457             
       
  1458             if ( KErrNone != err )
       
  1459                 {
       
  1460                 SVPDEBUG2( "CSVPSessionBase::HandleSessionStateChanged, err: %d", err )
       
  1461                 ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1462                 }
       
  1463             }
       
  1464         else if ( iHoldController->ResumeFailed() )
       
  1465             {
       
  1466             // Must terminate session; timer expired
       
  1467             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged Resume failed - Terminating" )
       
  1468                        
       
  1469             TRAPD( err, iSession->TerminateL() );
       
  1470             
       
  1471             if ( !err )
       
  1472                 {
       
  1473                 SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged Disconnecting" )
       
  1474                 ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting );
       
  1475                 
       
  1476                 TRAP( err, StartTimerL( KSVPMoHangupTerminatingTime,
       
  1477                         KSVPHangUpTimerExpired ) );
       
  1478                 
       
  1479                 if ( KErrNone != err )
       
  1480                     {
       
  1481                     SVPDEBUG2("CSVPSessionBase::HandleSessionStateChanged Hangup-timer error %d",
       
  1482                             err )
       
  1483                     }
       
  1484                 }
       
  1485             else
       
  1486                 {
       
  1487                 SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged - Term ERROR!" )
       
  1488                 }
       
  1489             }
       
  1490         else if ( iHoldController->HoldFailed() )
       
  1491             {
       
  1492             // Hold timer expired; no actions needed here
       
  1493             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged: Hold request failed - nothing to do" )
       
  1494             }
       
  1495         else
       
  1496             {
       
  1497             SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged - else" )
       
  1498             }
       
  1499         }
       
  1500     
       
  1501     SVPDEBUG1( "CSVPSessionBase::HandleSessionStateChanged Out" )
       
  1502     }
       
  1503 
       
  1504 // ---------------------------------------------------------------------------
       
  1505 // CSVPSessionBase::HandleStreamStateChange
       
  1506 // ---------------------------------------------------------------------------
       
  1507 //
       
  1508 void CSVPSessionBase::HandleStreamStateChange( CMceMediaStream& aStream )
       
  1509     {
       
  1510     SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream)  stream state= %d",
       
  1511             aStream.State() )
       
  1512     SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream)  stream  type= %d",
       
  1513         aStream.Type() )
       
  1514     SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream) session state= %d",
       
  1515         aStream.Session()->State() )
       
  1516 
       
  1517     if ( CMceMediaStream::EStreaming == aStream.State() &&
       
  1518          CMceSession::EOffering == aStream.Session()->State() )
       
  1519         {
       
  1520         SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream) early media started" )
       
  1521         ExecCbCallEventOccurred( MCCPCallObserver::ECCCSPEarlyMediaStarted );
       
  1522         iEarlyMediaOngoing = ETrue;
       
  1523         }
       
  1524     TBool bothStreamsDisabled ( ETrue );
       
  1525     TRAP_IGNORE( bothStreamsDisabled = IsBothStreamsDisabledL() );
       
  1526     if ( bothStreamsDisabled &&
       
  1527          CMceSession::EEstablished == aStream.Session()->State() && 
       
  1528          IsErrorInULandDLFirstTime() )
       
  1529         {
       
  1530         SetErrorInULandDLFirstTime( EFalse ); 
       
  1531         TRAP_IGNORE( StartTimerL( KSVPICMPErrorTime, KSVPICMPErrorTimerExpired ) )
       
  1532         }
       
  1533       else if ( !bothStreamsDisabled && !IsErrorInULandDLFirstTime() )
       
  1534           {
       
  1535           SetErrorInULandDLFirstTime( ETrue );
       
  1536           StopTimer ( KSVPICMPErrorTimerExpired );
       
  1537           }
       
  1538     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream) Out" )
       
  1539     }
       
  1540 
       
  1541 // ---------------------------------------------------------------------------
       
  1542 // CSVPSessionBase::HandleStreamStateChange
       
  1543 // ---------------------------------------------------------------------------
       
  1544 // 
       
  1545 void CSVPSessionBase::HandleStreamStateChange( CMceMediaStream& aStream,
       
  1546         CMceMediaSink& aSink )
       
  1547     {
       
  1548     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) In" )
       
  1549     
       
  1550     CMceSession::TState sessionState = CMceSession::ETerminated;
       
  1551     
       
  1552     if ( &aStream )
       
  1553         {
       
  1554         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) stream state=%d",
       
  1555                 aStream.State() )
       
  1556         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) stream type=%d",
       
  1557                 aStream.Type() )
       
  1558         }
       
  1559     
       
  1560     if ( &aStream && aStream.Session() )
       
  1561         {
       
  1562         sessionState = aStream.Session()->State();
       
  1563         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) session state=%d", sessionState )
       
  1564         }
       
  1565     
       
  1566     if ( &aSink )
       
  1567         {
       
  1568         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) is sink enabled=%d",
       
  1569                 aSink.IsEnabled() )
       
  1570 
       
  1571         if ( HasHoldController() && ESVPConnected == HoldController().HoldState() && 
       
  1572              !aSink.IsEnabled() && CMceSession::EEstablished == sessionState )
       
  1573             {
       
  1574             // Hold state is connected but sink is disabled -> try enable after a while
       
  1575             SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - Resume ICMP, Sink" )
       
  1576             TRAP_IGNORE( StartTimerL( KSVPSinkResumeICMPErrorTime, KSVPSinkResumeICMPErrorTimerExpired ) )
       
  1577             }
       
  1578         
       
  1579         else if ( !HasHoldController() && !aSink.IsEnabled() && CMceSession::EEstablished == sessionState && 
       
  1580                   CMceMediaStream::EDisabled == aStream.State() )
       
  1581             {
       
  1582             // Not a hold case, mediaStream and sink is disabled -> try enable after a while
       
  1583             SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - ICMP, Sink and MediaStream" )
       
  1584             if ( !IsSessionMuted() )
       
  1585                 {
       
  1586                 SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - ICMP, Sink not enabled -> enable" )
       
  1587                 aSink.EnableL();
       
  1588                 }
       
  1589             }
       
  1590         }
       
  1591     
       
  1592     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSink) Out" )
       
  1593     }
       
  1594 
       
  1595 // ---------------------------------------------------------------------------
       
  1596 // CSVPSessionBase::HandleStreamStateChange
       
  1597 // ---------------------------------------------------------------------------
       
  1598 //
       
  1599 void CSVPSessionBase::HandleStreamStateChange( CMceMediaStream& aStream,
       
  1600         CMceMediaSource& aSource )
       
  1601     {
       
  1602     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) In" )
       
  1603     
       
  1604     CMceSession::TState sessionState = CMceSession::ETerminated;
       
  1605     
       
  1606     if ( &aStream )
       
  1607         {
       
  1608         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) stream state=%d",
       
  1609                 aStream.State() )
       
  1610         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) stream type=%d",
       
  1611                 aStream.Type() )
       
  1612         }
       
  1613     
       
  1614     if ( &aStream && aStream.Session() )
       
  1615         {
       
  1616         sessionState = aStream.Session()->State();
       
  1617         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) session state=%d", sessionState )
       
  1618         }
       
  1619     
       
  1620     if ( &aSource )
       
  1621         {
       
  1622         SVPDEBUG2( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) is source enabled=%d",
       
  1623                 aSource.IsEnabled() )
       
  1624 
       
  1625         if ( HasHoldController() && ESVPConnected == HoldController().HoldState() && 
       
  1626              !aSource.IsEnabled() && CMceSession::EEstablished == sessionState )
       
  1627             {
       
  1628             // Hold state is connected but source is disabled -> try enable after a while
       
  1629             SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - Resume ICMP, Source" )
       
  1630             TRAP_IGNORE( StartTimerL( KSVPSourceResumeICMPErrorTime, KSVPSourceResumeICMPErrorTimerExpired ) )
       
  1631             }
       
  1632         
       
  1633         else if ( !HasHoldController() && !aSource.IsEnabled() && CMceSession::EEstablished == sessionState && 
       
  1634                   CMceMediaStream::EDisabled == aStream.State() )
       
  1635             {
       
  1636             // Not a hold case, mediaStream and source is disabled -> try enable after a while
       
  1637             SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - ICMP, Source and MediaStream" )
       
  1638             if ( !IsSessionMuted() )
       
  1639                 {
       
  1640                 SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange - ICMP, Source not enabled -> enable" )
       
  1641                 aSource.EnableL();
       
  1642                 }
       
  1643             }
       
  1644         }
       
  1645     
       
  1646     SVPDEBUG1( "CSVPSessionBase::HandleStreamStateChange(aStream,aSource) Out" )
       
  1647     }
       
  1648 
       
  1649 // ---------------------------------------------------------------------------
       
  1650 // CSVPSessionBase::SessionLocallyHeld, from MSVPHoldObserver
       
  1651 // ---------------------------------------------------------------------------
       
  1652 // 
       
  1653 void CSVPSessionBase::SessionLocallyHeld()
       
  1654     {
       
  1655     SVPDEBUG1( "CSVPSessionBase::SessionLocallyHeld In" )
       
  1656     
       
  1657     ExecCbCallStateChanged( MCCPCallObserver::ECCPStateHold );
       
  1658     iRtpObserver.ResetSessionInObserving( this );
       
  1659     
       
  1660     SVPDEBUG1( "CSVPSessionBase::SessionLocallyHeld Out" )
       
  1661     }
       
  1662 
       
  1663 // ---------------------------------------------------------------------------
       
  1664 // CSVPSessionBase::SessionLocallyResumed, from MSVPHoldObserver
       
  1665 // ---------------------------------------------------------------------------
       
  1666 // 
       
  1667 void CSVPSessionBase::SessionLocallyResumed()
       
  1668     {
       
  1669     SVPDEBUG1( "CSVPSessionBase::SessionLocallyResumed In" )
       
  1670     
       
  1671     ExecCbCallStateChanged( MCCPCallObserver::ECCPStateConnected );
       
  1672     iRtpObserver.ResetSessionInObserving( this );
       
  1673     
       
  1674     SVPDEBUG1( "CSVPSessionBase::SessionLocallyResumed Out" )
       
  1675     }
       
  1676 
       
  1677 // ---------------------------------------------------------------------------
       
  1678 // CSVPSessionBase::SessionRemoteHeld, from MSVPHoldObserver
       
  1679 // ---------------------------------------------------------------------------
       
  1680 // 
       
  1681 void CSVPSessionBase::SessionRemoteHeld()
       
  1682     {
       
  1683     SVPDEBUG1( "CSVPSessionBase::SessionRemoteHeld In" )
       
  1684     
       
  1685     ExecCbCallEventOccurred( MCCPCallObserver::ECCPRemoteHold );
       
  1686     iRtpObserver.ResetSessionInObserving( this );
       
  1687     
       
  1688     SVPDEBUG1( "CSVPSessionBase::SessionRemoteHeld Out" )
       
  1689     }
       
  1690 
       
  1691 // ---------------------------------------------------------------------------
       
  1692 // CSVPSessionBase::SessionRemoteResumed, from MSVPHoldObserver
       
  1693 // ---------------------------------------------------------------------------
       
  1694 // 
       
  1695 void CSVPSessionBase::SessionRemoteResumed()
       
  1696     {
       
  1697     SVPDEBUG1( "CSVPSessionBase::SessionRemoteResumed In" )
       
  1698     
       
  1699     ExecCbCallEventOccurred( MCCPCallObserver::ECCPRemoteResume );
       
  1700     iRtpObserver.ResetSessionInObserving( this );
       
  1701     
       
  1702     SVPDEBUG1( "CSVPSessionBase::SessionRemoteResumed Out" )
       
  1703     }
       
  1704 
       
  1705 // ---------------------------------------------------------------------------
       
  1706 // CSVPSessionBase::HoldRequestFailed, from MSVPHoldObserver
       
  1707 // ---------------------------------------------------------------------------
       
  1708 // 
       
  1709 void CSVPSessionBase::HoldRequestFailed()
       
  1710     {
       
  1711     SVPDEBUG1( "CSVPSessionBase::HoldRequestFailed In" )
       
  1712     
       
  1713     ExecCbErrorOccurred( ECCPLocalHoldFail );
       
  1714     
       
  1715     SVPDEBUG1( "CSVPSessionBase::HoldRequestFailed Out" )
       
  1716     }
       
  1717 
       
  1718 // ---------------------------------------------------------------------------
       
  1719 // CSVPSessionBase::ResumeRequestFailed, from MSVPHoldObserver
       
  1720 // ---------------------------------------------------------------------------
       
  1721 // 
       
  1722 void CSVPSessionBase::ResumeRequestFailed()
       
  1723     {
       
  1724     SVPDEBUG1( "CSVPSessionBase::ResumeRequestFailed In" )
       
  1725     
       
  1726     ExecCbErrorOccurred( ECCPLocalResumeFail );
       
  1727     
       
  1728     SVPDEBUG1( "CSVPSessionBase::ResumeRequestFailed Out" )
       
  1729     }
       
  1730 
       
  1731 // ---------------------------------------------------------------------------
       
  1732 // CSVPSessionBase::RemoteParty
       
  1733 // ---------------------------------------------------------------------------
       
  1734 // 
       
  1735 const TDesC& CSVPSessionBase::RemoteParty() const
       
  1736     {
       
  1737     delete iRecipient;
       
  1738     iRecipient = NULL;
       
  1739     
       
  1740     // RemotePartyL is used to handle leave situations
       
  1741     TRAPD( remoteErr, RemotePartyL() );
       
  1742     
       
  1743     if ( KErrNone != remoteErr )
       
  1744         {
       
  1745         // something went wrong, return null
       
  1746         SVPDEBUG2( "CSVPSessionBase::RemoteParty remoteErr=%d", remoteErr )
       
  1747         return KNullDesC;
       
  1748         }
       
  1749     else
       
  1750         {
       
  1751         return *iRecipient;
       
  1752         }
       
  1753     }
       
  1754 
       
  1755 // ---------------------------------------------------------------------------
       
  1756 // CSVPSessionBase::RemotePartyL
       
  1757 // ---------------------------------------------------------------------------
       
  1758 // 
       
  1759 void CSVPSessionBase::RemotePartyL() const
       
  1760     {
       
  1761     SVPDEBUG1( "CSVPSessionBase::RemotePartyL In" )
       
  1762     
       
  1763     // fetch recipient from Mce, convert recipient to 16-bit descriptor
       
  1764     if ( IsMobileOriginated() )
       
  1765         {
       
  1766         SVPDEBUG1( "CSVPSessionBase::RemotePartyL, mo case, Fetch: RECIPIENT" )
       
  1767         iRecipient = HBufC::NewL( iSession->Recipient().Length() );
       
  1768         iRecipient->Des().Copy( iSession->Recipient() );
       
  1769  
       
  1770         // remove all extra parameters from recipient address
       
  1771         TInt index = iRecipient->Des().FindF( KSVPSemiColon );
       
  1772         
       
  1773         if ( KErrNotFound != index )
       
  1774             {
       
  1775             iRecipient->Des().Delete( index, iRecipient->Length() );
       
  1776             // remove left bracket if exists
       
  1777             TInt bracketLocation = iRecipient->Locate( KSVPLeftBracket );
       
  1778             if ( KErrNotFound != bracketLocation )
       
  1779                 {
       
  1780                 iRecipient->Des().Delete( bracketLocation, 1 );
       
  1781                 }
       
  1782             }
       
  1783         
       
  1784         // check if anonymous address
       
  1785         index = iRecipient->Des().FindF( KSVPAnonymous );
       
  1786         if ( KErrNotFound != index )
       
  1787             {
       
  1788             // Anonymous address case
       
  1789             SVPDEBUG2( "CSVPSessionBase::RemotePartyL: Anonymous = %d", index )
       
  1790             iRecipient->Des().Copy( KNullDesC );
       
  1791             }
       
  1792         }
       
  1793     else 
       
  1794         {
       
  1795         SVPDEBUG1( "CSVPSessionBase::RemotePartyL, mt case, Fetch: ORIGINATOR" )
       
  1796         HBufC* uri = CSVPUriParser::ParseRemotePartyUriL( 
       
  1797             iSession->Originator() );
       
  1798         delete iRecipient;
       
  1799         iRecipient = uri;
       
  1800         uri = NULL;
       
  1801         }
       
  1802     
       
  1803     SVPDEBUG1( "CSVPSessionBase::RemotePartyL Out" )
       
  1804     }
       
  1805 
       
  1806 // ---------------------------------------------------------------------------
       
  1807 // CSVPSessionBase::RemotePartyName
       
  1808 // ---------------------------------------------------------------------------
       
  1809 // 
       
  1810 const TDesC& CSVPSessionBase::RemotePartyName()
       
  1811     {
       
  1812     SVPDEBUG1( "CSVPSessionBase::RemotePartyName()" )
       
  1813     
       
  1814     HBufC* displayName = NULL;
       
  1815     TRAPD( err, displayName = CSVPUriParser::ParseDisplayNameL( 
       
  1816         iSession->Originator() ) )
       
  1817 
       
  1818     if ( err || NULL == displayName ) 
       
  1819         {
       
  1820         SVPDEBUG1( "CSVPSessionBase::RemotePartyName, return KNullDesC" )
       
  1821         delete displayName;
       
  1822         displayName = NULL;
       
  1823         return KNullDesC;
       
  1824         }
       
  1825     else
       
  1826         {
       
  1827         delete iDisplayName;
       
  1828         iDisplayName = displayName;
       
  1829         displayName = NULL;
       
  1830         return *iDisplayName;
       
  1831         }    
       
  1832     }
       
  1833 
       
  1834 // ---------------------------------------------------------------------------
       
  1835 // CSVPSessionBase::DialledParty
       
  1836 // ---------------------------------------------------------------------------
       
  1837 // 
       
  1838 const TDesC& CSVPSessionBase::DialledParty() const
       
  1839     {
       
  1840     SVPDEBUG1( "CSVPSessionBase::DialledParty not implemented" )  
       
  1841     return KNullDesC;
       
  1842     }
       
  1843 
       
  1844 // ---------------------------------------------------------------------------
       
  1845 // CSVPSessionBase::State
       
  1846 // ---------------------------------------------------------------------------
       
  1847 //
       
  1848 MCCPCallObserver::TCCPCallState CSVPSessionBase::State() const
       
  1849     {
       
  1850     SVPDEBUG1( "CSVPSessionBase::State In" )
       
  1851     SVPDEBUG2( "CSVPSessionBase::State iSession->State()=%d", iSession->State() )
       
  1852     
       
  1853     // ccpState can be safely initialized with StatusIdle
       
  1854     MCCPCallObserver::TCCPCallState ccpState =
       
  1855         MCCPCallObserver::ECCPStateIdle;
       
  1856     
       
  1857     switch ( iSession->State() )
       
  1858         {
       
  1859         case CMceSession::EIdle:
       
  1860             {
       
  1861             SVPDEBUG1( "CSVPSessionBase::State EIdle received" )
       
  1862             ccpState = MCCPCallObserver::ECCPStateIdle;
       
  1863             break;
       
  1864             }
       
  1865         case CMceSession::EOffering:
       
  1866             {
       
  1867             SVPDEBUG1( "CSVPSessionBase::State EOffering received" )
       
  1868             ccpState = MCCPCallObserver::ECCPStateConnecting;
       
  1869             break;
       
  1870             }
       
  1871         case CMceSession::EIncoming:
       
  1872             {
       
  1873             SVPDEBUG1( "CSVPSessionBase::State EIncoming received" )
       
  1874             ccpState = MCCPCallObserver::ECCPStateAnswering;
       
  1875             break;
       
  1876             }
       
  1877         case CMceSession::EReserving:
       
  1878             {
       
  1879             SVPDEBUG1( "CSVPSessionBase::State EReserving received" )
       
  1880             ccpState = MCCPCallObserver::ECCPStateConnecting;
       
  1881             break;
       
  1882             }
       
  1883         case CMceSession::EAnswering: 
       
  1884             {
       
  1885             SVPDEBUG1( "CSVPSessionBase::State EAnswering received" )
       
  1886             ccpState = MCCPCallObserver::ECCPStateAnswering;
       
  1887             break;
       
  1888             }
       
  1889         case CMceSession::EProceeding:
       
  1890             {
       
  1891             SVPDEBUG1( "CSVPSessionBase::State EProceeding received" )
       
  1892             ccpState = MCCPCallObserver::ECCPStateConnecting;
       
  1893             break;
       
  1894             }
       
  1895         case CMceSession::EEstablished:
       
  1896             {
       
  1897             SVPDEBUG1( "CSVPSessionBase::State EEstablished received" )
       
  1898             ccpState = MCCPCallObserver::ECCPStateConnected;
       
  1899             if( iHoldController && ESVPOnHold == iHoldController->HoldState() )
       
  1900                 {
       
  1901                 SVPDEBUG1( "    CSVPSessionBase::State Established and holded" )
       
  1902                 ccpState = MCCPCallObserver::ECCPStateHold;
       
  1903                 }
       
  1904             break;
       
  1905             }
       
  1906         case CMceSession::ECancelling:
       
  1907             {
       
  1908             SVPDEBUG1( "CSVPSessionBase::State ECancelling received" )
       
  1909             ccpState = MCCPCallObserver::ECCPStateIdle;  
       
  1910             break;
       
  1911             }
       
  1912         case CMceSession::ETerminating:
       
  1913             {
       
  1914             SVPDEBUG1( "CSVPSessionBase::State ETerminating received" )
       
  1915             ccpState = MCCPCallObserver::ECCPStateDisconnecting;
       
  1916             break;
       
  1917             }
       
  1918         case CMceSession::ETerminated:
       
  1919             {
       
  1920             SVPDEBUG1( "CSVPSessionBase::State ETerminated received" )
       
  1921             
       
  1922             if ( MCCPCallObserver::ECCPStateDisconnecting == iSessionState )
       
  1923                 {
       
  1924                 SVPDEBUG1( "CSVPSessionBase::State Saving state for termination timer" )
       
  1925                 ccpState = MCCPCallObserver::ECCPStateDisconnecting;
       
  1926                 }
       
  1927             else
       
  1928                 {
       
  1929                 ccpState = MCCPCallObserver::ECCPStateIdle;     
       
  1930                 }
       
  1931             
       
  1932             break;
       
  1933             }
       
  1934         default:
       
  1935             {
       
  1936             SVPDEBUG1( "CSVPSessionBase::State DEFAULT" )
       
  1937             // This block should never be reached.
       
  1938             __ASSERT_DEBUG( EFalse, User::Panic(
       
  1939                     KSVPName, KSVPPanicBadArgument ) );
       
  1940             break;
       
  1941             }
       
  1942         }
       
  1943     
       
  1944     SVPDEBUG2( "CSVPSessionBase::State Out return=%d", ccpState )
       
  1945     return ccpState;
       
  1946     }
       
  1947 
       
  1948 // ---------------------------------------------------------------------------
       
  1949 // CSVPSessionBase::GetKeepAliveTime
       
  1950 // ---------------------------------------------------------------------------
       
  1951 //    
       
  1952 TInt CSVPSessionBase::GetKeepAliveTime()
       
  1953     {
       
  1954     return iKeepAliveValue;
       
  1955     }
       
  1956 
       
  1957 // ---------------------------------------------------------------------------
       
  1958 // CSVPSessionBase::Type
       
  1959 // ---------------------------------------------------------------------------
       
  1960 //
       
  1961 TUid CSVPSessionBase::Uid() const
       
  1962     {
       
  1963     return KSVPImplementationUid;
       
  1964     }
       
  1965 
       
  1966 
       
  1967 // ---------------------------------------------------------------------------
       
  1968 // CSVPSessionBase::Conference
       
  1969 // ---------------------------------------------------------------------------
       
  1970 //
       
  1971 MCCPConferenceCall* CSVPSessionBase::ConferenceProviderL( 
       
  1972     const MCCPConferenceCallObserver& /*aObserver*/ )
       
  1973     {
       
  1974 	return NULL;    
       
  1975 	}
       
  1976 	
       
  1977 // ---------------------------------------------------------------------------
       
  1978 // CSVPSessionBase::IsSecured
       
  1979 // ---------------------------------------------------------------------------
       
  1980 //
       
  1981 TBool CSVPSessionBase::IsSecured() const
       
  1982     {
       
  1983 	SVPDEBUG2( "CSVPSessionBase::IsSecured: %d", iSecured )
       
  1984 	return iSecured;    
       
  1985 	}
       
  1986 
       
  1987 // ---------------------------------------------------------------------------
       
  1988 // CSVPSessionBase::IsMobileOriginated
       
  1989 // ---------------------------------------------------------------------------
       
  1990 //
       
  1991 TBool CSVPSessionBase::IsMobileOriginated() const
       
  1992     {
       
  1993 	SVPDEBUG1( "CSVPSessionBase::IsMobileOriginated" )
       
  1994 	return EFalse;    
       
  1995 	}
       
  1996 
       
  1997 // ---------------------------------------------------------------------------
       
  1998 // CSVPSessionBase::IsCallForwarded
       
  1999 // ---------------------------------------------------------------------------
       
  2000 //
       
  2001 TBool CSVPSessionBase::IsCallForwarded() const
       
  2002     {
       
  2003     return EFalse;
       
  2004     }
       
  2005 
       
  2006 // ---------------------------------------------------------------------------
       
  2007 // CSVPSessionBase::Swap
       
  2008 // ---------------------------------------------------------------------------
       
  2009 //
       
  2010 TInt CSVPSessionBase::Swap()
       
  2011     {
       
  2012     return KErrNotSupported;
       
  2013     }
       
  2014 
       
  2015 // ---------------------------------------------------------------------------
       
  2016 // CSVPSessionBase::Caps
       
  2017 // ---------------------------------------------------------------------------
       
  2018 // 
       
  2019 MCCPCallObserver::TCCPCallControlCaps CSVPSessionBase::Caps() const
       
  2020     {
       
  2021     SVPDEBUG1( "CSVPSessionBase::Caps return ECCPCapsPSCall" )
       
  2022     return MCCPCallObserver::ECCPCapsPSCall;
       
  2023     }
       
  2024 
       
  2025 // ---------------------------------------------------------------------------
       
  2026 // CSVPSessionBase::Release
       
  2027 // ---------------------------------------------------------------------------
       
  2028 //    
       
  2029 TInt CSVPSessionBase::Release()
       
  2030     {
       
  2031     return KErrNotSupported;
       
  2032     }
       
  2033 
       
  2034 // ---------------------------------------------------------------------------
       
  2035 // CSVPSessionBase::Dial
       
  2036 // ---------------------------------------------------------------------------
       
  2037 //
       
  2038 TInt CSVPSessionBase::Dial()
       
  2039     {
       
  2040     return KErrNotSupported;
       
  2041     }
       
  2042 
       
  2043 // ---------------------------------------------------------------------------
       
  2044 // CSVPSessionBase::Answer
       
  2045 // ---------------------------------------------------------------------------
       
  2046 //
       
  2047 TInt CSVPSessionBase::Answer()
       
  2048     {
       
  2049     return KErrNotSupported;
       
  2050     }
       
  2051 
       
  2052 // ---------------------------------------------------------------------------
       
  2053 // CSVPSessionBase::Cancel
       
  2054 // ---------------------------------------------------------------------------
       
  2055 //
       
  2056 TInt CSVPSessionBase::Cancel()
       
  2057     {
       
  2058     return KErrNotSupported;
       
  2059     }
       
  2060 
       
  2061 // ---------------------------------------------------------------------------
       
  2062 // CSVPSessionBase::Reject
       
  2063 // ---------------------------------------------------------------------------
       
  2064 // 
       
  2065 TInt CSVPSessionBase::Reject()
       
  2066     {
       
  2067     return KErrNotSupported;
       
  2068     }
       
  2069 
       
  2070 // ---------------------------------------------------------------------------
       
  2071 // CSVPSessionBase::Queue
       
  2072 // ---------------------------------------------------------------------------
       
  2073 // 
       
  2074 TInt CSVPSessionBase::Queue()
       
  2075     {
       
  2076     return KErrNotSupported;
       
  2077     }
       
  2078 
       
  2079 // ---------------------------------------------------------------------------
       
  2080 // CSVPSessionBase::Ringing
       
  2081 // ---------------------------------------------------------------------------
       
  2082 // 
       
  2083 TInt CSVPSessionBase::Ringing()
       
  2084     {
       
  2085     return KErrNotSupported;  
       
  2086     }
       
  2087    
       
  2088 // ---------------------------------------------------------------------------
       
  2089 // CSVPSessionBase::TransferProvider
       
  2090 // ---------------------------------------------------------------------------
       
  2091 //
       
  2092 MCCPTransferProvider* CSVPSessionBase::TransferProviderL(
       
  2093      const MCCPTransferObserver& aObserver )
       
  2094     {
       
  2095     SVPDEBUG1( "CSVPSessionBase::TransferProviderL In" )
       
  2096     
       
  2097     if ( !iTransferController )
       
  2098         {
       
  2099         iTransferController = CSVPTransferController::NewL( 
       
  2100                                                         iSession,
       
  2101                                                         this,
       
  2102                                                         iContainer, 
       
  2103                                                         *this );
       
  2104         iTransferController->AddObserverL( aObserver );
       
  2105         }
       
  2106     
       
  2107     SVPDEBUG1( "CSVPSessionBase::TransferProviderL Out" )
       
  2108     return iTransferController;
       
  2109 	}
       
  2110 
       
  2111 // ---------------------------------------------------------------------------
       
  2112 // CSVPSessionBase::ForwardProviderL
       
  2113 // ---------------------------------------------------------------------------
       
  2114 //
       
  2115 MCCPForwardProvider* CSVPSessionBase::ForwardProviderL(
       
  2116      const MCCPForwardObserver& /*aObserver*/ )
       
  2117     {
       
  2118     return NULL;
       
  2119     }
       
  2120 
       
  2121 
       
  2122 // transfer observer
       
  2123 
       
  2124 // ---------------------------------------------------------------------------
       
  2125 // From MSVPTransferObserver
       
  2126 // Notifier for succesful transfer.
       
  2127 // ---------------------------------------------------------------------------
       
  2128 // 
       
  2129 void CSVPSessionBase::TransferNotification( TInt aNotifyCode )
       
  2130     {
       
  2131     SVPDEBUG2( "CSVPSessionBase::TransferNotification In, aNotifyCode: %d",
       
  2132         aNotifyCode );
       
  2133     
       
  2134     if ( ESVPTransferOKHangUp == aNotifyCode )
       
  2135         {
       
  2136         SVPDEBUG1( "CSVPSessionBase::TransferNotification: ESVPTransferOKHangUp" )
       
  2137         // Transfer complete - hang up current session.
       
  2138         HangUp();
       
  2139         }
       
  2140     else if ( ESVPTransferDecline == aNotifyCode )
       
  2141         {
       
  2142         SVPDEBUG1( "CSVPSessionBase::TransferNotification: ESVPTransferDecline" )
       
  2143         // Inform application - transfer was rejected by the other party,
       
  2144         // not a failure, to be precise
       
  2145         ExecCbErrorOccurred( ECCPTransferFailed );
       
  2146         }
       
  2147     else if ( ESVPIncomingRefer == aNotifyCode )
       
  2148         {
       
  2149         SVPDEBUG1( "CSVPSessionBase::TransferNotification: ESVPIncomingRefer" )
       
  2150         // Currently no CallEventOccurred notify to the observer
       
  2151         }
       
  2152     else
       
  2153         {
       
  2154         // Internal transfer error if comes here
       
  2155         SVPDEBUG1( "CSVPSessionBase::TransferNotification: Unknown notify" )
       
  2156         }
       
  2157     
       
  2158     SVPDEBUG1( "CSVPSessionBase::TransferNotification Out" )
       
  2159     }
       
  2160 
       
  2161 // ---------------------------------------------------------------------------
       
  2162 // From MSVPTransferObserver
       
  2163 // Notifier for transfer failure.
       
  2164 // ---------------------------------------------------------------------------
       
  2165 //
       
  2166 #ifdef _DEBUG
       
  2167 void CSVPSessionBase::TransferFailed( TInt aError )
       
  2168 #else
       
  2169 void CSVPSessionBase::TransferFailed( TInt /*aError*/ )
       
  2170 #endif  // _DEBUG
       
  2171     {
       
  2172     SVPDEBUG1( "CSVPSessionBase::TransferFailed In" )
       
  2173     SVPDEBUG2(" CSVPSessionBase::TransferFailed aError=%d", aError )
       
  2174     
       
  2175     // Inform application about the error
       
  2176     ExecCbErrorOccurred( ECCPTransferFailed );
       
  2177     
       
  2178     SVPDEBUG1( "CSVPSessionBase::TransferFailed Out" )
       
  2179     }
       
  2180 
       
  2181 //  from CCP DTMF provider
       
  2182 // ---------------------------------------------------------------------------
       
  2183 // CSVPSessionBase::CancelDtmfStringSending
       
  2184 // ---------------------------------------------------------------------------
       
  2185 // 
       
  2186 TInt CSVPSessionBase::CancelDtmfStringSending()
       
  2187     {
       
  2188     SVPDEBUG1( "CSVPSessionBase::CancelDtmfStringSending In" )
       
  2189     
       
  2190     TInt dtmfErr( KErrNone );
       
  2191     
       
  2192     if ( !iSVPUtility.GetDTMFMode() ) 
       
  2193         {
       
  2194         dtmfErr = KErrNotFound;
       
  2195         if ( iEventGenerator )
       
  2196             {
       
  2197             iEventGenerator->StopEvents();
       
  2198             dtmfErr = KErrNone;
       
  2199             }
       
  2200         }
       
  2201     else 
       
  2202         {
       
  2203         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2204         TInt count = streams.Count();
       
  2205         while( count )
       
  2206             {
       
  2207             count--;
       
  2208             CMceMediaStream& mediaStream = *streams[ count ];
       
  2209             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2210                 {
       
  2211                 TRAP( dtmfErr, mediaStream.Source()->CancelDtmfToneSequenceL() );
       
  2212                 }
       
  2213             else
       
  2214                 {
       
  2215                 dtmfErr = KErrNotSupported;
       
  2216                 }
       
  2217             
       
  2218             if ( KErrNone != dtmfErr )
       
  2219                 {
       
  2220                 return dtmfErr;
       
  2221                 }
       
  2222             }
       
  2223         }
       
  2224     
       
  2225     SVPDEBUG2( "CSVPSessionBase::CancelDtmfStringSending Out return=%d", dtmfErr )
       
  2226     return dtmfErr;
       
  2227     }
       
  2228 
       
  2229 // ---------------------------------------------------------------------------
       
  2230 // CSVPSessionBase::StartDtmfTone
       
  2231 // ---------------------------------------------------------------------------
       
  2232 //
       
  2233 TInt CSVPSessionBase::StartDtmfTone( const TChar aTone )
       
  2234     {
       
  2235     SVPDEBUG1( "CSVPSessionBase::StartDtmfTone In" )
       
  2236     
       
  2237     TInt dtmfErr( KErrNone );
       
  2238     
       
  2239     if ( iSVPUtility.GetDTMFMode() )
       
  2240         {
       
  2241         SVPDEBUG1( "CSVPSessionBase::StartDtmfTone DTMF Outband" )
       
  2242         // fetch streams
       
  2243         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2244         TInt count = streams.Count();
       
  2245         while ( count )
       
  2246             {
       
  2247             count--;
       
  2248             CMceMediaStream& mediaStream = *streams[ count ];
       
  2249             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2250                 {
       
  2251                 TRAP( dtmfErr, mediaStream.Source()->StartDtmfToneL( aTone ) );
       
  2252                 }
       
  2253             else
       
  2254                 {
       
  2255                 dtmfErr = KErrNotSupported;
       
  2256                 }
       
  2257             
       
  2258             if ( KErrNone != dtmfErr )
       
  2259                 {
       
  2260                 SVPDEBUG2( "CSVPSessionBase::StartDtmfToneL dtmfErr: %d",
       
  2261                     dtmfErr )
       
  2262                 
       
  2263                 return dtmfErr;
       
  2264                 }
       
  2265             }
       
  2266         }
       
  2267     else
       
  2268         {
       
  2269         SVPDEBUG1( "CSVPSessionBase::StartDtmfTone DTMF Inband" )
       
  2270         iDtmfTone = aTone;
       
  2271         DtmfObserver().HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfManualStart, 
       
  2272                                         KErrNone, 
       
  2273                                         aTone );
       
  2274         }
       
  2275     
       
  2276     SVPDEBUG2( "CSVPSessionBase::StartDtmfTone Out return=%d", dtmfErr )
       
  2277     return dtmfErr;
       
  2278     }
       
  2279 
       
  2280 // ---------------------------------------------------------------------------
       
  2281 // CSVPSessionBase::StopDtmfTone
       
  2282 // ---------------------------------------------------------------------------
       
  2283 //
       
  2284 TInt CSVPSessionBase::StopDtmfTone()
       
  2285     {
       
  2286     SVPDEBUG1( "CSVPSessionBase::StopDtmfTone In" )
       
  2287     
       
  2288     TInt dtmfErr( KErrNone );
       
  2289     
       
  2290     if ( iSVPUtility.GetDTMFMode() )
       
  2291         {
       
  2292         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2293         TInt count = streams.Count();
       
  2294         while( count )
       
  2295             {
       
  2296             count--;
       
  2297             CMceMediaStream& mediaStream = *streams[ count ];
       
  2298             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2299                 {
       
  2300                 TRAP( dtmfErr, mediaStream.Source()->StopDtmfToneL() );
       
  2301                 }
       
  2302             // NOP with inband.
       
  2303             
       
  2304             if ( KErrNone != dtmfErr )
       
  2305                 {
       
  2306                 SVPDEBUG2( "CSVPSessionBase::StopDtmfTone dtmfErr: %d",
       
  2307                     dtmfErr )
       
  2308                 
       
  2309                 return dtmfErr;
       
  2310                 }
       
  2311             }
       
  2312         }
       
  2313     else
       
  2314         {
       
  2315         DtmfObserver().HandleDTMFEvent( MCCPDTMFObserver::ECCPDtmfManualStop, 
       
  2316                                         KErrNone, 
       
  2317                                         iDtmfTone );
       
  2318         }
       
  2319 
       
  2320     SVPDEBUG2( "CSVPSessionBase::StopDtmfTone Out return=%d", dtmfErr )
       
  2321     return dtmfErr;
       
  2322     }
       
  2323 
       
  2324 // ---------------------------------------------------------------------------
       
  2325 // CSVPSessionBase::SendDtmfToneString
       
  2326 // ---------------------------------------------------------------------------
       
  2327 //
       
  2328 TInt CSVPSessionBase::SendDtmfToneString( const TDesC& aString )
       
  2329     {
       
  2330     SVPDEBUG1( "CSVPSessionBase::SendDtmfToneString In" )
       
  2331     
       
  2332     TInt dtmfErr( KErrNone );
       
  2333     TChar dtmfPause('p');
       
  2334     // MCE calls if outband DTMF.
       
  2335     // Exception is pause character 'p' which is handled always locally
       
  2336     if ( !iSVPUtility.GetDTMFMode() ||
       
  2337          ( aString.Length() == 1 &&
       
  2338            dtmfPause == aString[0] ) ) 
       
  2339         {
       
  2340         SVPDEBUG1( "CSVPSessionBase::SendDtmfToneString Inband" )
       
  2341         
       
  2342         delete iDtmfString;
       
  2343         iDtmfString = NULL;
       
  2344         TRAP( dtmfErr, iDtmfString = HBufC::NewL( aString.Length() ) );
       
  2345         if ( KErrNone != dtmfErr )
       
  2346             {
       
  2347             return dtmfErr;
       
  2348             }
       
  2349                 
       
  2350         *iDtmfString = aString;
       
  2351         iDtmfLex.Assign( *iDtmfString );
       
  2352         
       
  2353         if ( !iEventGenerator )
       
  2354             {
       
  2355             TRAP( dtmfErr,
       
  2356             iEventGenerator = CSVPDTMFEventGenerator::NewL( *this ) );
       
  2357             }
       
  2358         
       
  2359         if ( KErrNone != dtmfErr )
       
  2360             {
       
  2361             SVPDEBUG2( "CSVPSessionBase::SendDtmfToneString IB dtmfErr: %d",
       
  2362                 dtmfErr )
       
  2363             
       
  2364             return dtmfErr;
       
  2365             }
       
  2366         
       
  2367         // Dtmf pause length is 2500ms
       
  2368         TBool pauseChar = ( aString.Length() == 1 && 
       
  2369                             dtmfPause == aString[0] ); 
       
  2370         // start events
       
  2371         iEventGenerator->StartDtmfEvents( aString.Length(), pauseChar );
       
  2372         }
       
  2373     else
       
  2374         {
       
  2375         SVPDEBUG1( "CSVPSessionBase::SendDtmfToneString Outband" )
       
  2376         
       
  2377         const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2378         TInt count = streams.Count();
       
  2379         while( count )
       
  2380             {
       
  2381             count--;
       
  2382             CMceMediaStream& mediaStream = *streams[ count ];
       
  2383             
       
  2384             if ( SVPAudioUtility::DtmfActionCapableStream( mediaStream ) )
       
  2385                 {
       
  2386                 TRAP( dtmfErr,
       
  2387                     mediaStream.Source()->SendDtmfToneSequenceL( aString ) );
       
  2388                 }
       
  2389             else
       
  2390                 {
       
  2391                 dtmfErr = KErrNotSupported;
       
  2392                 }
       
  2393             
       
  2394             if ( KErrNone != dtmfErr )
       
  2395                 {
       
  2396                 SVPDEBUG2( "CSVPSessionBase::SendDtmfToneString Out OB dtmfErr: %d", dtmfErr )
       
  2397                 return dtmfErr;
       
  2398                 }
       
  2399             }
       
  2400         }
       
  2401     
       
  2402     SVPDEBUG2( "CSVPSessionBase::SendDtmfToneString Out return=%d", dtmfErr )
       
  2403     return dtmfErr;
       
  2404     }
       
  2405 
       
  2406 
       
  2407 // from MSVPPropertyWatchObserver
       
  2408 // ---------------------------------------------------------------------------
       
  2409 // CSVPSessionBase::ValueChangedL
       
  2410 // ---------------------------------------------------------------------------
       
  2411 //
       
  2412 void CSVPSessionBase::ValueChangedL( TInt aKey, TInt aValue )
       
  2413     {
       
  2414     SVPDEBUG3("CSVPSessionBase::ValueChangedL In aKey: %d, aValue: %d ", aKey, aValue )
       
  2415 
       
  2416     // fetch streams from session
       
  2417     const RPointerArray<CMceMediaStream>& streams = iSession->Streams();
       
  2418 
       
  2419     switch ( aKey )
       
  2420         {
       
  2421         case KTelMicrophoneMuteState:
       
  2422             {
       
  2423             PerformMuteChangeL( streams, aValue );
       
  2424             break;
       
  2425             }
       
  2426         default:
       
  2427             {
       
  2428             SVPDEBUG1( "CSVPSessionBase::ValueChangedL DEFAULT - NOP" )
       
  2429             break;
       
  2430             }
       
  2431         }
       
  2432     
       
  2433     SVPDEBUG1( "CSVPSessionBase::ValueChangedL Out" )
       
  2434     }
       
  2435 
       
  2436 // ---------------------------------------------------------------------------
       
  2437 // CSVPSessionBase::PerformMuteChangeL
       
  2438 // ---------------------------------------------------------------------------
       
  2439 //
       
  2440 void CSVPSessionBase::PerformMuteChangeL(
       
  2441         const RPointerArray<CMceMediaStream>& aStreams, TInt aValue )
       
  2442     {
       
  2443     SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL In" )
       
  2444     
       
  2445     if ( CMceSession::EOffering == iSession->State() ||
       
  2446          iHoldController && ESVPOnHold == iHoldController->HoldState() )
       
  2447         {
       
  2448 		// call is ringing or on hold, we don't perform mute or unmute
       
  2449         SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL, no need for mute nor unmute" )
       
  2450         }
       
  2451     else
       
  2452         {
       
  2453         for ( TInt i = 0; i < aStreams.Count(); i++ )
       
  2454             {
       
  2455             if ( IsMobileOriginated() )
       
  2456                 {
       
  2457                 if ( aStreams[ i ]->Source() )
       
  2458                     {
       
  2459                     if ( EPSTelMicMuteOn == aValue )
       
  2460                         {
       
  2461                         // mute mic source
       
  2462                         SVPAudioUtility::DisableMicSourceL(
       
  2463                                 *( aStreams[ i ]->Source() ) );
       
  2464                         }
       
  2465                     else
       
  2466                         {
       
  2467                         // un-mute mic source            
       
  2468                         SVPAudioUtility::EnableMicSourceL(
       
  2469                                 *( aStreams[ i ]->Source() ) );
       
  2470                         }
       
  2471                     }
       
  2472                 }
       
  2473             else
       
  2474                 {
       
  2475                 if( CMceSession::EEstablished == iSession->State() )
       
  2476                     {
       
  2477                     if ( EPSTelMicMuteOn == aValue )
       
  2478                         {
       
  2479                         // mute mic source
       
  2480                         SVPAudioUtility::DisableMicSourceL(
       
  2481                                 *( aStreams[ i ]->BoundStreamL().Source() ) );
       
  2482                         }
       
  2483                     else
       
  2484                         {
       
  2485                         // un-mute mic source            
       
  2486                         SVPAudioUtility::EnableMicSourceL(
       
  2487                                 *( aStreams[ i ]->BoundStreamL().Source() ) );
       
  2488                         }
       
  2489                     }
       
  2490                 }
       
  2491             }
       
  2492         
       
  2493         if ( EPSTelMicMuteOff == aValue )
       
  2494             {
       
  2495             SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL - Enable Speaker" )
       
  2496             SVPAudioUtility::EnableSpeakerSinksL( aStreams );
       
  2497             }
       
  2498         }
       
  2499 
       
  2500     if ( EPSTelMicMuteOn == aValue ) { iMuted = ETrue; }
       
  2501     if ( EPSTelMicMuteOff == aValue ) { iMuted = EFalse; }
       
  2502 
       
  2503     if ( iHoldController )
       
  2504         {
       
  2505         SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL - update mute status" )
       
  2506         iHoldController->Muted( iMuted );
       
  2507         }
       
  2508 
       
  2509     SVPDEBUG1( "CSVPSessionBase::PerformMuteChangeL Out" )    
       
  2510     }
       
  2511 
       
  2512 // ---------------------------------------------------------------------------
       
  2513 // CSVPSessionBase::PropertyDeleted
       
  2514 // ---------------------------------------------------------------------------
       
  2515 //
       
  2516 #ifdef _DEBUG
       
  2517 void CSVPSessionBase::PropertyDeleted( TInt aKey )
       
  2518 #else
       
  2519 void CSVPSessionBase::PropertyDeleted( TInt /*aKey*/ )
       
  2520 #endif // __DEBUG
       
  2521     {
       
  2522     SVPDEBUG2("CSVPSessionBase::PropertyDeleted aKey=%d", aKey )
       
  2523     }
       
  2524 
       
  2525 
       
  2526 // from MSVPVolumeUpdateObserver    
       
  2527 // ---------------------------------------------------------------------------
       
  2528 // CSVPSessionBase::VolumeChanged
       
  2529 // ---------------------------------------------------------------------------
       
  2530 //  
       
  2531 void CSVPSessionBase::VolumeChanged( TInt aVolume )
       
  2532     {
       
  2533 #ifdef _DEBUG
       
  2534     TRAPD( volErr, VolumeChangedL( aVolume ) );
       
  2535     SVPDEBUG2("CSVPSessionBase::VolumeChanged volErr=%d", volErr )
       
  2536 #else
       
  2537     TRAP_IGNORE( VolumeChangedL( aVolume ) )
       
  2538 #endif // _DEBUG
       
  2539     }
       
  2540 
       
  2541 // ---------------------------------------------------------------------------
       
  2542 // CSVPSessionBase::VolumeChangedL
       
  2543 // ---------------------------------------------------------------------------
       
  2544 // 
       
  2545 void CSVPSessionBase::VolumeChangedL( TInt aVolume )
       
  2546     {
       
  2547     SVPDEBUG1( "CSVPSessionBase::VolumeChangedL In" )
       
  2548     
       
  2549     // fetch streams from session
       
  2550     const RPointerArray<CMceMediaStream>& stream = iSession->Streams();
       
  2551     
       
  2552     for ( TInt i = 0; i < stream.Count(); i++ )
       
  2553         {
       
  2554         // fetch mediastreams for handling
       
  2555         CMceMediaStream* mediaStream = stream[ i ];
       
  2556         CMceMediaStream& boundStream = mediaStream->BoundStreamL();
       
  2557         
       
  2558         // fetch sinks from current stream
       
  2559         const RPointerArray<CMceMediaSink>& sinks = mediaStream->Sinks();
       
  2560         
       
  2561         for ( TInt y = 0; y < sinks.Count(); y++ )
       
  2562             {
       
  2563             // find speaker sink
       
  2564             if ( KMceSpeakerSink == sinks[ y ]->Type() )
       
  2565                 {
       
  2566                 SVPDEBUG1( "CSVPSessionBase::VolumeChangedL Speaker found(A)" )
       
  2567                 CMceSpeakerSink* speakerSink =
       
  2568                         static_cast<CMceSpeakerSink*>( sinks[ y ] );
       
  2569                 // get sink max volume and adjust setVol accordingly
       
  2570                 TInt maxVol = speakerSink->MaxVolumeL();
       
  2571                 TInt setVol = maxVol * aVolume / KMaxPhoneVolume;
       
  2572 
       
  2573                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL maxVol=%d", maxVol )
       
  2574                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL aVolume=%d", aVolume )
       
  2575                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL setVol=%d", setVol )
       
  2576 
       
  2577                 speakerSink->SetVolumeL( setVol );
       
  2578                 }
       
  2579             } 
       
  2580         
       
  2581         const RPointerArray<CMceMediaSink>& boundSinks = boundStream.Sinks();
       
  2582         
       
  2583         for ( TInt z = 0; z < boundSinks.Count(); z++ )
       
  2584             {
       
  2585             // find speaker sink from bound stream
       
  2586             if ( KMceSpeakerSink == boundSinks[ z ]->Type() )
       
  2587                 {
       
  2588                 SVPDEBUG1( "CSVPSessionBase::VolumeChangedL Speaker found(B)" )
       
  2589                 
       
  2590                 CMceSpeakerSink* speakerSink =
       
  2591                         static_cast<CMceSpeakerSink*>( boundSinks[ z ] );
       
  2592                 // get sink max volume and adjust setVol accordingly
       
  2593                 TInt maxVol = speakerSink->MaxVolumeL();
       
  2594                 TInt setVol = maxVol * aVolume / KMaxPhoneVolume;
       
  2595                 
       
  2596                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL maxVol=%d", maxVol )
       
  2597                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL aVolume=%d", aVolume )
       
  2598                 SVPDEBUG2("CSVPSessionBase::VolumeChangedL setVol=%d", setVol )
       
  2599 
       
  2600                 speakerSink->SetVolumeL( setVol );
       
  2601                 }
       
  2602             }
       
  2603         }
       
  2604     
       
  2605     SVPDEBUG1( "CSVPSessionBase::VolumeChangedL Out" )
       
  2606     }
       
  2607 
       
  2608 // ---------------------------------------------------------------------------
       
  2609 // CSVPSessionBase::SecureMandatory
       
  2610 // ---------------------------------------------------------------------------
       
  2611 // 
       
  2612 TBool CSVPSessionBase::SecureMandatory() const
       
  2613     {
       
  2614     SVPDEBUG2( "CSVPSessionBase::SecureMandatory=%d", iSecureMandatory )
       
  2615     return iSecureMandatory;
       
  2616     }
       
  2617 
       
  2618 // ---------------------------------------------------------------------------
       
  2619 // CSVPSessionBase::SecurePreferred
       
  2620 // ---------------------------------------------------------------------------
       
  2621 // 
       
  2622 TBool CSVPSessionBase::SecurePreferred() const
       
  2623     {
       
  2624     SVPDEBUG2( "CSVPSessionBase::SecurePreferred=%d", iSecurePreferred )
       
  2625     return iSecurePreferred;
       
  2626     }
       
  2627 
       
  2628 // ---------------------------------------------------------------------------
       
  2629 // CSVPSessionBase::SetSecureMandatory
       
  2630 // ---------------------------------------------------------------------------
       
  2631 // 
       
  2632 void CSVPSessionBase::SetSecureMandatory( TBool aSecMandatory )
       
  2633     {
       
  2634     iSecureMandatory = aSecMandatory;
       
  2635     }
       
  2636 
       
  2637 // ---------------------------------------------------------------------------
       
  2638 // CSVPSessionBase::SetSecurePreferred
       
  2639 // ---------------------------------------------------------------------------
       
  2640 // 
       
  2641 void CSVPSessionBase::SetSecurePreferred( TBool aSecPreferred )
       
  2642     {
       
  2643     iSecurePreferred = aSecPreferred;
       
  2644     }
       
  2645 
       
  2646 // ---------------------------------------------------------------------------
       
  2647 // CSVPSessionBase::SetCallEventToBeSent
       
  2648 // ---------------------------------------------------------------------------
       
  2649 // 
       
  2650 void CSVPSessionBase::SetCallEventToBeSent( MCCPCallObserver::TCCPCallEvent aCallEventToBeSent )
       
  2651     {
       
  2652     SVPDEBUG1( "CSVPSessionBase::SetCallEventToBeSent" )
       
  2653     iCallEventToBeSent = aCallEventToBeSent;
       
  2654     }
       
  2655 
       
  2656 // ---------------------------------------------------------------------------
       
  2657 // CSVPSessionBase::SetParameters
       
  2658 // ---------------------------------------------------------------------------
       
  2659 // 
       
  2660 void CSVPSessionBase::SetParameters( 
       
  2661     const CCCPCallParameters& /*aNewParams*/ )
       
  2662     {
       
  2663     SVPDEBUG1( "CSVPSessionBase::SetParameters - NOP" )
       
  2664     }
       
  2665 
       
  2666 // ---------------------------------------------------------------------------
       
  2667 // CSVPSessionBase::Parameters
       
  2668 // ---------------------------------------------------------------------------
       
  2669 // 
       
  2670 const CCCPCallParameters& CSVPSessionBase::Parameters() const
       
  2671     {
       
  2672     SVPDEBUG1( "CSVPSessionBase::Parameters In" )
       
  2673     return *iCallParameters;
       
  2674     }
       
  2675 
       
  2676 // ---------------------------------------------------------------------------
       
  2677 // CSVPSessionBase::Tone
       
  2678 // ---------------------------------------------------------------------------
       
  2679 //    
       
  2680 TCCPTone CSVPSessionBase::Tone() const
       
  2681     {
       
  2682     SVPDEBUG2( "CSVPSessionBase::Tone iTone: %d", iTone )
       
  2683     return iTone;
       
  2684     }
       
  2685     
       
  2686 // ---------------------------------------------------------------------------
       
  2687 // CSVPSessionBase::SetCryptoContextL
       
  2688 // ---------------------------------------------------------------------------
       
  2689 //
       
  2690 void CSVPSessionBase::SetCryptoContextL()
       
  2691     {
       
  2692     SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL In" )
       
  2693     
       
  2694     if ( KMceSessionSecure == iSession->Type() )
       
  2695         {
       
  2696         // get supported crypto contexts
       
  2697         if ( IsMobileOriginated() )
       
  2698             {
       
  2699             SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL Secure Mo" )
       
  2700             
       
  2701             const RArray<TMceCryptoContext>& cryptoContext = 
       
  2702                 static_cast<CMceSecureOutSession*> ( iSession )->
       
  2703                 SupportedCryptoContextsL();
       
  2704             SVPDEBUG2( "CSVPSessionBase::SetCryptoContextL Supported crypto context count=%d",
       
  2705                     cryptoContext.Count() )
       
  2706             
       
  2707             // set crypto contexts to session
       
  2708             static_cast<CMceSecureOutSession*> ( iSession )->
       
  2709                 SetCryptoContextsL( cryptoContext );
       
  2710             }
       
  2711         else
       
  2712             {
       
  2713             SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL Secure Mt" )
       
  2714             
       
  2715             const RArray<TMceCryptoContext>& cryptoContext = 
       
  2716             static_cast<CMceSecureInSession*> ( iSession )->
       
  2717                 SupportedCryptoContextsL();
       
  2718             SVPDEBUG2( "CSVPSessionBase::SetCryptoContextL Supported crypto context count=%d",
       
  2719                     cryptoContext.Count() )
       
  2720             
       
  2721             // set crypto contexts to session
       
  2722             static_cast<CMceSecureInSession*> ( iSession )->
       
  2723                 SetCryptoContextsL( cryptoContext );
       
  2724             }
       
  2725         }
       
  2726     
       
  2727     SVPDEBUG1( "CSVPSessionBase::SetCryptoContextL Out" )
       
  2728     }
       
  2729 
       
  2730 // ---------------------------------------------------------------------------
       
  2731 // CSVPSessionBase::CheckMmfPrioritiesForDtmfL
       
  2732 // ---------------------------------------------------------------------------
       
  2733 //
       
  2734 void CSVPSessionBase::CheckMmfPrioritiesForDtmfL(
       
  2735     const RPointerArray<CMceMediaStream>& aAudioStreams ) const
       
  2736     {
       
  2737     SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL In" )
       
  2738     
       
  2739     RPointerArray<CMceMediaSource> micsToEnable;
       
  2740     CleanupClosePushL( micsToEnable );
       
  2741     const TInt streamCount( aAudioStreams.Count() );
       
  2742     
       
  2743     SVPDEBUG2("CSVPSessionBase::CheckMmfPrioritiesForDtmfL streamCount: %d",
       
  2744         streamCount )
       
  2745     
       
  2746     // First disable the mic before doing any priority updating.
       
  2747     for ( TInt s = 0; s < streamCount; s++ )
       
  2748         {
       
  2749         CMceMediaSource* mic = aAudioStreams[s]->Source();
       
  2750         
       
  2751         if ( mic && KMceMicSource == mic->Type() && mic->IsEnabled() )
       
  2752             {
       
  2753             SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL disable mic 1" )
       
  2754             mic->DisableL();
       
  2755             micsToEnable.AppendL( mic );
       
  2756             }
       
  2757         
       
  2758         // At this point we must have a bound stream, otherwise the session
       
  2759         // would be a bit incomplete. Thus can and should leave here if bound
       
  2760         // stream is not found.
       
  2761         mic = NULL;
       
  2762         mic = aAudioStreams[s]->BoundStreamL().Source();
       
  2763         
       
  2764         if ( mic && KMceMicSource == mic->Type() && mic->IsEnabled() )
       
  2765             {
       
  2766             SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL disable mic 2" )
       
  2767             mic->DisableL();
       
  2768             micsToEnable.AppendL( mic );
       
  2769             }
       
  2770         
       
  2771         mic = NULL;
       
  2772         }
       
  2773     
       
  2774     // Set the correct priority and preference values.
       
  2775     for ( TInt k = 0; k < streamCount; k++ )
       
  2776         {
       
  2777         // No need to check against BoundStream(), see comments above.
       
  2778         if ( KMceAudio == aAudioStreams[k]->Type() )
       
  2779             {
       
  2780             SVPDEBUG2( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL round: %d start", k )
       
  2781             CMceAudioStream* stream = static_cast<CMceAudioStream*>( aAudioStreams[k] );
       
  2782             
       
  2783             TBool dtmfMode = EFalse;
       
  2784             
       
  2785             if ( SVPAudioUtility::IsDownlinkStream( *stream ) )
       
  2786                 {
       
  2787                 dtmfMode = SVPAudioUtility::SetPriorityCodecValuesL( *stream,
       
  2788                     static_cast<CMceAudioStream&>( stream->BoundStreamL() ) );
       
  2789                 }
       
  2790             else
       
  2791                 {
       
  2792                 dtmfMode = SVPAudioUtility::SetPriorityCodecValuesL(
       
  2793                     static_cast<CMceAudioStream&>( stream->BoundStreamL() ),
       
  2794                         *stream );
       
  2795                 }
       
  2796             
       
  2797             iSVPUtility.SetDtmfMode( dtmfMode );
       
  2798             
       
  2799             SVPDEBUG2( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL round: %d done", k )
       
  2800             }
       
  2801         }
       
  2802     
       
  2803     // Priorities are now correct, so update the session.
       
  2804     iSession->UpdateL();
       
  2805     
       
  2806     // Now enable mics after we have correct priorities.
       
  2807     const TInt mics = micsToEnable.Count();
       
  2808     
       
  2809     for ( TInt t = 0; t < mics; t++ )
       
  2810         {
       
  2811         SVPDEBUG2( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL enabling mics, round: %d", t )
       
  2812         micsToEnable[t]->EnableL();
       
  2813         }
       
  2814     
       
  2815     // Mics not owned
       
  2816     CleanupStack::PopAndDestroy( &micsToEnable );
       
  2817     
       
  2818     SVPDEBUG1( "CSVPSessionBase::CheckMmfPrioritiesForDtmfL Out" )
       
  2819     }
       
  2820 
       
  2821 // ---------------------------------------------------------------------------
       
  2822 // CSVPSessionBase::SessionStateChangedL
       
  2823 // ---------------------------------------------------------------------------
       
  2824 //
       
  2825 void CSVPSessionBase::SessionStateChangedL( TInt aOrigStatus,
       
  2826     TCCPError aError, TInt aModStatus )
       
  2827     {
       
  2828     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL In" )
       
  2829     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL aOrigStatus=%d",
       
  2830         aOrigStatus )
       
  2831     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL aError=%d",
       
  2832         aError )
       
  2833     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL aModStatus=%d",
       
  2834         aModStatus )
       
  2835     
       
  2836     // secure status was "secure call mandatory", only secure allowed
       
  2837     if ( KErrNone != aModStatus && SecureMandatory() )
       
  2838         {
       
  2839         if ( KSVPNotAcceptableHereVal == aModStatus ||
       
  2840              KSVPNotAcceptableVal == aModStatus ||
       
  2841              KSVPPreconditionFailureVal == aModStatus ||
       
  2842              KSVPMethodNotAllowedVal == aModStatus )
       
  2843             {
       
  2844             SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - Secure session failed!" )
       
  2845             // secure call failed due to recipients restrictions
       
  2846             User::LeaveIfError( ExecCbErrorOccurred( ECCPSecureCallFailed ) );
       
  2847             }
       
  2848         else
       
  2849             {
       
  2850             // secure call failed with SIP error response
       
  2851             // inform application about the error response received
       
  2852             User::LeaveIfError( ExecCbErrorOccurred( aError ) );
       
  2853             
       
  2854             // start termination timer, needed for UI
       
  2855             // to handle Disconnected-bubble   
       
  2856             StartTimerL( KSVPTerminatingTime, KSVPTerminationTimerExpired );
       
  2857             User::LeaveIfError( ExecCbCallStateChanged( MCCPCallObserver::ECCPStateDisconnecting ) );
       
  2858             }
       
  2859         }
       
  2860    
       
  2861     if ( KSVPRingingVal == aOrigStatus )
       
  2862         {
       
  2863         SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - 180 ringing received" )
       
  2864         User::LeaveIfError( ExecCbCallStateChanged( MCCPCallObserver::ECCPStateConnecting ) );
       
  2865         if ( iEarlyMediaOngoing )
       
  2866             {
       
  2867             // early media event is sent again to avoid simultaneous early media and ringback tone
       
  2868             SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL ringing ja earlymedia flag on" )
       
  2869             ExecCbCallEventOccurred( MCCPCallObserver::ECCCSPEarlyMediaStarted );
       
  2870             iEarlyMediaOngoing = EFalse;
       
  2871             }
       
  2872         }
       
  2873     
       
  2874     if ( KSVPQueuedVal == aOrigStatus )
       
  2875         {
       
  2876         SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - 182 queued received" )
       
  2877         User::LeaveIfError( ExecCbSsEventOccurred( MCCPSsObserver::ESsCallWaiting ) );
       
  2878         }
       
  2879     
       
  2880     switch( iSession->State() )
       
  2881         {
       
  2882         case CMceSession::EEstablished:
       
  2883             {
       
  2884             // stop mt drop out timer or mo invite timer
       
  2885             StopTimers();
       
  2886             
       
  2887             // mute status must be checked again in Mt -> 
       
  2888             // there might be one call already in mute state        
       
  2889             TInt value( EPSTelMicMuteOff );
       
  2890             RProperty::Get( KPSUidTelMicrophoneMuteStatus, 
       
  2891                     KTelMicrophoneMuteState, value );
       
  2892             
       
  2893             // check initial mute status 
       
  2894             if ( EPSTelMicMuteOn == value )
       
  2895                 {
       
  2896                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Mute: ON" )
       
  2897                 ValueChangedL( KTelMicrophoneMuteState, EPSTelMicMuteOn );
       
  2898                 }
       
  2899             // secure session created successfully, set iSecured flag to ETrue
       
  2900             if ( KMceSessionSecure == iSession->Type() && 
       
  2901                  CMceSession::EControlPathSecure == iSession->ControlPathSecurityLevel() )
       
  2902                 {
       
  2903                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - Secure session created" )
       
  2904                 iSecured = ETrue;
       
  2905                 }
       
  2906             else
       
  2907                 {
       
  2908                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - Non-secure session created" )
       
  2909                 iSecured = EFalse;
       
  2910                 if ( SecurePreferred() )
       
  2911                     {
       
  2912                     // Secure preferred but unsecure session created -> send info to ccp api
       
  2913                     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - secure was preferred" )
       
  2914                     iCallEventToBeSent = MCCPCallObserver::ECCPNotSecureCall;
       
  2915                     }
       
  2916                 }
       
  2917             
       
  2918             // We need get the call state now because session state will
       
  2919             // change when doing CheckMmfPrioritiesForDtmfL because it updates
       
  2920             // the session. This leads into 'Offering' state which will
       
  2921             // panic our State() function call.
       
  2922             // Note: session's state will fall back to 'Established' because
       
  2923             // the priority update does not lead into a real update.
       
  2924             MCCPCallObserver::TCCPCallState callState = State();
       
  2925             
       
  2926             // We need to check MMF priorities only in MO case if really
       
  2927             // neccessary
       
  2928             if ( IsMobileOriginated() &&
       
  2929                  SVPAudioUtility::MmfPriorityUpdateNeededL( iSession->Streams() ) )
       
  2930                 {
       
  2931                 CheckMmfPrioritiesForDtmfL( iSession->Streams() );
       
  2932                 }
       
  2933             if ( IsMobileOriginated() )
       
  2934                 {
       
  2935                 TBool sessionUpdateOngoing = EFalse;
       
  2936                 UpdateKeepAliveL( *iSession, sessionUpdateOngoing );
       
  2937                 }
       
  2938             
       
  2939             // enable speaker sink
       
  2940             SVPAudioUtility::EnableSpeakerSinksL( iSession->Streams() );
       
  2941             // call state callback
       
  2942             User::LeaveIfError( ExecCbCallStateChanged( callState ) );
       
  2943             
       
  2944             // 'NotSecure' call event must be sent after the
       
  2945             // 'callstatechanged' - event, not before because phone needs an
       
  2946             // active call for playing the unsecure tone.
       
  2947             if ( MCCPCallObserver::ECCPSecureNotSpecified != iCallEventToBeSent )
       
  2948                 {
       
  2949                  if ( MCCPCallObserver::ECCPSecureCall == iCallEventToBeSent ||
       
  2950                      MCCPCallObserver::ECCPNotSecureCall == iCallEventToBeSent )
       
  2951                     {
       
  2952                     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - sending secure specific call event" )
       
  2953                     User::LeaveIfError( ExecCbCallEventOccurred( iCallEventToBeSent ) );
       
  2954                     }
       
  2955                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL - sending remotePartyInfoChanged event" )
       
  2956                 User::LeaveIfError( ExecCbCallEventOccurred( MCCPCallObserver::ECCPNotifyRemotePartyInfoChange ) );
       
  2957                 iCallEventToBeSent = MCCPCallObserver::ECCPSecureNotSpecified;
       
  2958                 }
       
  2959             break;
       
  2960             }
       
  2961         case CMceSession::EAnswering:
       
  2962         case CMceSession::EReserving:
       
  2963         case CMceSession::EIncoming:
       
  2964         case CMceSession::EOffering:
       
  2965             {
       
  2966             SVPDEBUG1( "CSVPSessionBase:SessionStateChangedL: No action" )
       
  2967             break;
       
  2968             }
       
  2969         case CMceSession::ECancelling:
       
  2970         case CMceSession::EIdle:
       
  2971         case CMceSession::ETerminating:
       
  2972         case CMceSession::EProceeding:
       
  2973             {
       
  2974             SVPDEBUG1( "CSVPSessionBase:SessionStateChangedL: Callback state change" )
       
  2975             User::LeaveIfError( ExecCbCallStateChanged( State() ) );
       
  2976             break;
       
  2977             }
       
  2978         case CMceSession::ETerminated:
       
  2979             {
       
  2980             SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Terminated" )
       
  2981             
       
  2982             if ( MCCPCallObserver::ECCPStateDisconnecting != iSessionState &&
       
  2983                  MCCPCallObserver::ECCPStateIdle != iSessionState &&
       
  2984                  iCCPSessionObserver )
       
  2985                 {
       
  2986                 // probably some SIP error occurred, inform client
       
  2987                 if ( aOrigStatus < 0 )
       
  2988                 	{
       
  2989                     SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL, aOrigStatus=%d", aOrigStatus )
       
  2990                     
       
  2991                     switch ( aOrigStatus )
       
  2992                         {
       
  2993                         case KErrSIPForbidden:
       
  2994                             {
       
  2995                             User::LeaveIfError( ExecCbErrorOccurred( ECCPErrorNoService ) );
       
  2996                             }
       
  2997                             break;
       
  2998                         default:
       
  2999                             {
       
  3000                             User::LeaveIfError( ExecCbErrorOccurred( ECCPGlobalFailure ) );
       
  3001                             }
       
  3002                             break;
       
  3003                         }
       
  3004                     }
       
  3005                 
       
  3006                 if ( KErrNone != aModStatus )
       
  3007                     {
       
  3008                     User::LeaveIfError( ExecCbErrorOccurred( aError ) );
       
  3009                     }
       
  3010                 
       
  3011                 iSessionState = MCCPCallObserver::ECCPStateDisconnecting;
       
  3012                 iTerminatingRepeat = 0;
       
  3013                 
       
  3014                 StartTimerL( KSVPTerminatingTime, KSVPTerminationTimerExpired );
       
  3015                 User::LeaveIfError( ExecCbCallStateChanged( State() ) );
       
  3016                 
       
  3017                 // Termination engaged by the remote end ->
       
  3018                 // Client is informed with ECCPRemoteTerminated event
       
  3019                 // This prevents automatic unhold when two calls, 
       
  3020                 // one on hold and one active, exist.
       
  3021                 if ( !iAlreadyTerminating )
       
  3022                     {
       
  3023                     User::LeaveIfError( ExecCbCallEventOccurred(
       
  3024                             MCCPCallObserver::ECCPRemoteTerminated ) );
       
  3025                     }
       
  3026                 }
       
  3027             else if ( iCCPSessionObserver )
       
  3028                 {
       
  3029                 User::LeaveIfError( ExecCbCallStateChanged(
       
  3030                         MCCPCallObserver::ECCPStateIdle ) );
       
  3031                 }
       
  3032             else
       
  3033                 {
       
  3034                 SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Session creation failed in early stage - terminate" )
       
  3035                 iObserver.TerminateSession(  (CMceInSession&) Session() );
       
  3036                 }
       
  3037             break;
       
  3038             }
       
  3039         default:
       
  3040             {
       
  3041             SVPDEBUG1( "CSVPSessionBase:SessionStateChangedL DEFAULT" )
       
  3042             break;
       
  3043             }
       
  3044         }
       
  3045     
       
  3046     SVPDEBUG1( "CSVPSessionBase::SessionStateChangedL Out" )
       
  3047     }
       
  3048 
       
  3049 // ---------------------------------------------------------------------------
       
  3050 // CSVPSessionBase::UpdateKeepAliveL
       
  3051 // ---------------------------------------------------------------------------
       
  3052 //
       
  3053 void CSVPSessionBase::UpdateKeepAliveL( CMceSession& aSession, 
       
  3054         TBool aSessionUpdateOngoing )
       
  3055     {
       
  3056     SVPDEBUG1( "CSVPSessionBase:UpdateKeepAliveL In" )
       
  3057     
       
  3058     // update keepalive -> mo and mt
       
  3059     SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL Starting CN handling" )
       
  3060     
       
  3061     const RPointerArray<CMceMediaStream>& streamArray = aSession.Streams();
       
  3062     TInt streamCount( streamArray.Count() );
       
  3063     TBool cnInAnswer = EFalse;
       
  3064     
       
  3065     for ( TInt i = 0; i < streamCount; i++ )
       
  3066         {
       
  3067         CMceAudioStream* stream = static_cast<CMceAudioStream*>( streamArray[ i ] );
       
  3068         
       
  3069         if ( iSVPUtility.IsComfortNoise( *stream ) )
       
  3070             {
       
  3071             cnInAnswer = ETrue;
       
  3072             SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL CN Found" )
       
  3073             iSVPUtility.SetCNKeepAliveL( *stream, iKeepAliveValue );
       
  3074             }
       
  3075         }
       
  3076     
       
  3077     if ( !cnInAnswer )
       
  3078         {
       
  3079         SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL CN NOT Found" )
       
  3080         SVPDEBUG2( "CSVPSessionBase::SessionStateChangedL Streamcount: %d", streamCount )
       
  3081         
       
  3082         while( streamCount-- )
       
  3083             {
       
  3084             CMceAudioStream* stream = static_cast< CMceAudioStream* >( streamArray[ streamCount ] );
       
  3085             iSVPUtility.SetKeepAliveL( *stream, iKeepAliveValue );
       
  3086             }
       
  3087         }
       
  3088     
       
  3089     if ( !aSessionUpdateOngoing )
       
  3090         {
       
  3091         SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL  -> UPDATE" )
       
  3092         aSession.UpdateL();
       
  3093         SVPDEBUG1( "CSVPSessionBase::UpdateKeepAliveL  -> UPDATE DONE" )
       
  3094         }
       
  3095     SVPDEBUG1("CSVPSessionBase:UpdateKeepAliveL Out")
       
  3096     }
       
  3097 
       
  3098 // ---------------------------------------------------------------------------
       
  3099 // CSVPSessionBase::UpdateFailed
       
  3100 // ---------------------------------------------------------------------------
       
  3101 //    
       
  3102 void CSVPSessionBase::UpdateFailed( CMceSession& aSession, TInt aStatusCode )
       
  3103     {
       
  3104     SVPDEBUG1( "CSVPSessionBase::UpdateFailed In" )
       
  3105     SVPDEBUG2( "CSVPSessionBase::UpdateFailed aStatusCode=%d", aStatusCode )
       
  3106     
       
  3107     // Check if MCE Session has changed
       
  3108     if ( &Session() != &aSession )
       
  3109         {
       
  3110         // And if, then update to the current session
       
  3111         SVPDEBUG1( "CSVPSessionBase::UpdateFailed - update MCE Session" )
       
  3112         delete iSession;
       
  3113         iSession = &aSession;
       
  3114         }
       
  3115     
       
  3116     if ( iHoldController )
       
  3117         {
       
  3118         iHoldController->RequestFailed( aSession, aStatusCode, *this );
       
  3119         }
       
  3120     
       
  3121     SVPDEBUG1( "CSVPSessionBase::UpdateFailed Out" )
       
  3122     }
       
  3123 
       
  3124 
       
  3125 // ---------------------------------------------------------------------------
       
  3126 // CSVPSessionBase::SetRtpKeepAliveL
       
  3127 // ---------------------------------------------------------------------------
       
  3128 //
       
  3129 void CSVPSessionBase::SetRtpKeepAliveL( CMceSession* /*aSession*/, 
       
  3130                                         TBool /*aSessionUpdateOngoing*/ )
       
  3131     {
       
  3132     SVPDEBUG1( "CSVPSessionBase::SetRtpKeepAliveL" )
       
  3133     }
       
  3134 
       
  3135 // ---------------------------------------------------------------------------
       
  3136 // CSVPSessionBase::SetUpdatedSession
       
  3137 // ---------------------------------------------------------------------------
       
  3138 //
       
  3139 void CSVPSessionBase::SetUpdatedSession( CMceInSession* aUpdatedSession )
       
  3140     {
       
  3141     SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession In" )
       
  3142     
       
  3143     delete iSession;
       
  3144     iSession = aUpdatedSession;
       
  3145 
       
  3146 	// lets check should mic be muted 
       
  3147     const RPointerArray<CMceMediaStream>& streamsArray = iSession->Streams(); 
       
  3148     const TInt streamCount( streamsArray.Count() );
       
  3149     if ( streamCount && iMuted )
       
  3150         {
       
  3151         SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession Mic should be muted" )
       
  3152         
       
  3153         if ( IsMobileOriginated() ) 
       
  3154             {
       
  3155             for ( TInt i = 0; i < streamCount; i++ )
       
  3156                 {
       
  3157                 if ( streamsArray[i]->Source()->IsEnabled() )
       
  3158                     {
       
  3159                     SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession Mic is not muted" )
       
  3160                     SVPDEBUG1( " -> disable mic" )
       
  3161                     streamsArray[i]->Source()->DisableL();
       
  3162                     }
       
  3163                 else 
       
  3164                     {
       
  3165                     SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession Mic is already" )
       
  3166                     SVPDEBUG1( " muted -> no need to disable mic" )
       
  3167                     }
       
  3168                 }
       
  3169             }
       
  3170         else
       
  3171             {
       
  3172             // mute mic source
       
  3173             for ( TInt i = 0; i < streamCount; i++ )
       
  3174                 {
       
  3175                 if ( streamsArray[i]->BoundStreamL().Source()->IsEnabled() )
       
  3176                     {
       
  3177                     streamsArray[i]->BoundStreamL().Source()->DisableL();
       
  3178                     }
       
  3179                 }
       
  3180             }
       
  3181         }
       
  3182 
       
  3183     // Update changed session also to the transfercontroller
       
  3184     if ( iTransferController )
       
  3185         {
       
  3186         SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession also to the transfercontroller" )
       
  3187         iTransferController->SetMceSessionObject( aUpdatedSession );
       
  3188         }
       
  3189 
       
  3190     SVPDEBUG1( "CSVPSessionBase::SetUpdatedSession Out" )
       
  3191     }
       
  3192 
       
  3193 // ---------------------------------------------------------------------------
       
  3194 // CSVPSessionBase::SetEmptyReInvite
       
  3195 // ---------------------------------------------------------------------------
       
  3196 //
       
  3197 void CSVPSessionBase::SetEmptyReInvite()
       
  3198     {
       
  3199     SVPDEBUG1( "CSVPSessionBase::SetEmptyReInvite In" )
       
  3200     iEmptyReInvite = ETrue;
       
  3201     }
       
  3202 
       
  3203 // ---------------------------------------------------------------------------
       
  3204 // CSVPSessionBase::IsEmptyReInvite
       
  3205 // ---------------------------------------------------------------------------
       
  3206 //
       
  3207 TBool CSVPSessionBase::IsEmptyReInvite()
       
  3208     {
       
  3209     SVPDEBUG1( "CSVPSessionBase::IsEmptyReInvite In" )
       
  3210     return iEmptyReInvite;
       
  3211     }
       
  3212 
       
  3213 // ---------------------------------------------------------------------------
       
  3214 // CSVPSessionBase::IsIdle
       
  3215 // ---------------------------------------------------------------------------
       
  3216 //
       
  3217 TBool CSVPSessionBase::IsIdle()
       
  3218     {
       
  3219     SVPDEBUG1( "CSVPSessionBase::IsIdle In" )
       
  3220     return ( MCCPCallObserver::ECCPStateIdle == iSessionState );
       
  3221     }
       
  3222 
       
  3223 // ---------------------------------------------------------------------------
       
  3224 // CSVPSessionBase::SecureSpecified
       
  3225 // ---------------------------------------------------------------------------
       
  3226 //
       
  3227 TBool CSVPSessionBase::SecureSpecified( ) const 
       
  3228    {
       
  3229    return ETrue;
       
  3230    }
       
  3231 
       
  3232 // ---------------------------------------------------------------------------
       
  3233 // CSVPSessionBase::SetErrorInULandDLFirstTime
       
  3234 // ---------------------------------------------------------------------------
       
  3235 //
       
  3236 void CSVPSessionBase::SetErrorInULandDLFirstTime( TBool aFirstTime )
       
  3237     {
       
  3238     iErrorInULandDLFirstTime = aFirstTime;
       
  3239     SVPDEBUG2("CSVPSessionBase::SetErrorInULandDLFirstTime=%d",iErrorInULandDLFirstTime)
       
  3240     }
       
  3241 
       
  3242 // ---------------------------------------------------------------------------
       
  3243 // CSVPSessionBase::IsErrorInULandDLFirstTime
       
  3244 // ---------------------------------------------------------------------------
       
  3245 //
       
  3246 TBool CSVPSessionBase::IsErrorInULandDLFirstTime()
       
  3247     {
       
  3248     SVPDEBUG2("CSVPSessionBase::IsErrorInULandDLFirstTime=%d",iErrorInULandDLFirstTime)
       
  3249     return iErrorInULandDLFirstTime;
       
  3250     }
       
  3251 
       
  3252 
       
  3253 // ---------------------------------------------------------------------------
       
  3254 // CSVPSessionBase::IsBothStreamsDisabledL
       
  3255 // ---------------------------------------------------------------------------
       
  3256 //
       
  3257 TBool CSVPSessionBase::IsBothStreamsDisabledL() const
       
  3258     {
       
  3259     SVPDEBUG1( "CSVPSessionBase::IsBothStreamsDisabledL() In" )
       
  3260     TBool bothStreamsDisabled = ETrue;
       
  3261     const RPointerArray<CMceMediaStream>& streams = Session().Streams();
       
  3262     TInt streamsCount = streams.Count();
       
  3263 
       
  3264     for ( TInt i = 0; i < streamsCount; i++ )
       
  3265         {
       
  3266         if( streams[ i ]->State() != CMceMediaStream::EDisabled || 
       
  3267             streams[ i ]->BoundStreamL().State() != CMceMediaStream::EDisabled )
       
  3268             {
       
  3269             bothStreamsDisabled = EFalse;
       
  3270             }
       
  3271         }
       
  3272 
       
  3273     SVPDEBUG2("CSVPSessionBase::IsBothStreamsDisabledL Out,ret=%d",bothStreamsDisabled)
       
  3274     return bothStreamsDisabled;
       
  3275     }
       
  3276 
       
  3277 // ---------------------------------------------------------------------------
       
  3278 // CSVPSessionBase::IsSessionMuted
       
  3279 // ---------------------------------------------------------------------------
       
  3280 //
       
  3281 TBool CSVPSessionBase::IsSessionMuted() const
       
  3282     {
       
  3283     SVPDEBUG2("CSVPSessionBase::IsSessionMuted: %d", iMuted )
       
  3284     return iMuted;
       
  3285     }
       
  3286 
       
  3287 // ---------------------------------------------------------------------------
       
  3288 // CSVPSessionBase::IsCLIROnL
       
  3289 // ---------------------------------------------------------------------------
       
  3290 //
       
  3291 TBool CSVPSessionBase::IsCLIROnL() const
       
  3292     {
       
  3293     return iSVPUtility.IsCLIROnL();
       
  3294     }