vtengines/videoteleng/CallCtrl/Src/CVtCtlVideoCall.cpp
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Video call abstraction implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #pragma CTC SKIP
       
    20 // INCLUDE FILES
       
    21 #include    "CVtCtlVideoCall.h"
       
    22 #include    "CVtCtlCallStatusMonitor.h"
       
    23 #include    "VtCtlPanic.h"
       
    24 #include    "cvtlogger.h"
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CVtCtlVideoCall::CVtCtlVideoCall
       
    31 // C++ constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 /*****************************************************
       
    36 *   Series 60 Customer / ETel
       
    37 *   Series 60  ETel API
       
    38 *****************************************************/
       
    39 CVtCtlVideoCall::CVtCtlVideoCall( 
       
    40     RMobileLine& aDataLine,
       
    41     TVtCtlSessionId aId,
       
    42     MVtCtlCallStatusObserver& aObserver ) 
       
    43     : iLine( aDataLine ), iObserver( aObserver )
       
    44     {
       
    45     __VTPRINTENTER( "CVtCtlVideoCall.CVtCtlVideoCall" )
       
    46     iCallInfo.iId = aId;
       
    47     __VTPRINTEXIT( "CVtCtlVideoCall.CVtCtlVideoCall" )
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CVtCtlVideoCall::NewL
       
    52 // Two-phased constructor.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 /*****************************************************
       
    56 *   Series 60 Customer / ETel
       
    57 *   Series 60  ETel API
       
    58 *****************************************************/
       
    59 CVtCtlVideoCall* CVtCtlVideoCall::NewL( 
       
    60     RMobileLine& aDataLine,
       
    61     TVtCtlSessionId aId,
       
    62     MVtCtlCallStatusObserver& aObserver )
       
    63     {
       
    64     __VTPRINTENTER( "CVtCtlVideoCall.NewL" )
       
    65     CVtCtlVideoCall* self = new( ELeave ) 
       
    66         CVtCtlVideoCall( aDataLine, aId, aObserver );
       
    67     __VTPRINTEXIT( "CVtCtlVideoCall.NewL" )
       
    68     return self;
       
    69     }
       
    70 
       
    71     
       
    72 // Destructor
       
    73 CVtCtlVideoCall::~CVtCtlVideoCall()
       
    74     {
       
    75     __VTPRINTENTER( "CVtCtlVideoCall.~" )
       
    76     __VTPRINT( DEBUG_SESSION | DEBUG_DESTRUCT, "VtCtl:Call~")
       
    77     delete iStatusMonitor;
       
    78     if ( iCall )
       
    79     	{
       
    80     	iCall->Close();
       
    81     	delete iCall;
       
    82     	}
       
    83     __VTPRINTEXIT( "CVtCtlVideoCall.~" )
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CVtCtlVideoCall::CallInfo
       
    88 // Returns call information containing information not associated to ETel
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 const CVtCtlVideoCall::TVtCtlCallInfo& CVtCtlVideoCall::CallInfo() const
       
    92     {
       
    93     return iCallInfo;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CVtCtlVideoCall::MobileInfo
       
    98 // Returns ETel call information.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 /*****************************************************
       
   102 *   Series 60 Customer / ETel
       
   103 *   Series 60  ETel API
       
   104 *****************************************************/
       
   105 const RMobileCall::TMobileCallInfoV1& CVtCtlVideoCall::MobileInfo() const
       
   106     {
       
   107     return iMobileCallInfo;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CVtCtlVideoCall::InitializeCallL
       
   112 // Opens call subsession and starts status monitor.
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 /*****************************************************
       
   116 *   Series 60 Customer / ETel
       
   117 *   Series 60  ETel API
       
   118 *****************************************************/
       
   119 void CVtCtlVideoCall::InitializeCallL( 
       
   120     RMobileCall& aCall )
       
   121     {
       
   122     __VTPRINTENTER( "CVtCtlVideoCall.InitializeCallL" )
       
   123     __ASSERT_ALWAYS( iLine.SubSessionHandle(), 
       
   124         Panic( EVtCtlPanicLineHandleNull ) );
       
   125     iCall = &aCall;
       
   126     iStatusMonitor = new ( ELeave ) CVtCtlCallStatusMonitor( *iCall, *this );
       
   127     iStatusMonitor->Start();
       
   128     UpdateCallInfo();
       
   129     iCallInfo.iPreviousStatus = MVtCtlCallControl::EIdle;
       
   130     iCallInfo.iStatus = 
       
   131         CVtCtlCallStatusMonitor::MapState( iMobileCallInfo.iStatus );
       
   132 
       
   133     __VTPRINTEXIT( "CVtCtlVideoCall.InitializeCallL" )
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CVtCtlVideoCall::UpdateCallInfo
       
   138 // Updates call information from ETel
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 /*****************************************************
       
   142 *   Series 60 Customer / ETel
       
   143 *   Series 60  ETel API
       
   144 *****************************************************/
       
   145 TInt CVtCtlVideoCall::UpdateCallInfo()
       
   146     {
       
   147     __VTPRINTENTER( "CVtCtlVideoCall.UpdateCallInfo" )
       
   148     __ASSERT_ALWAYS( iCall->SubSessionHandle(), 
       
   149         Panic( EVtCtlPanicCallHandleNull ) );
       
   150         
       
   151     RMobileCall::TMobileCallInfoV1Pckg pckg( iMobileCallInfo );
       
   152     const TInt err( iCall->GetMobileCallInfo( pckg ) );
       
   153     __VTPRINT2( DEBUG_SESSION, "VtCtl:Call. dir %d",
       
   154         iMobileCallInfo.iRemoteParty.iDirection )
       
   155     __VTPRINT2( DEBUG_SESSION, "VtCtl:Call. status %d",
       
   156         iMobileCallInfo.iStatus )
       
   157 #ifdef VTDEBUG
       
   158     RDebug::Print(_L(" VtCtl.RemoteNumber=%S"),
       
   159         &iMobileCallInfo.iRemoteParty.iRemoteNumber.iTelNumber );
       
   160 #endif
       
   161     __VTPRINTEXITR( "CVtCtlVideoCall.UpdateCallInfo err=%d", err )
       
   162     return err;
       
   163     }
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CVtCtlVideoCall::GetDuration
       
   167 // Returns call duration
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 TInt CVtCtlVideoCall::GetDuration( TVtCtlDuration& aDuration )
       
   171     {
       
   172     __VTPRINTENTER( "CVtCtlVideoCall.GetDuration" )
       
   173     const TInt res( UpdateCallInfo() );
       
   174     if ( res == KErrNone )
       
   175         {
       
   176         aDuration = iMobileCallInfo.iDuration;
       
   177         }
       
   178     __VTPRINTEXITR( "CVtCtlVideoCall.GetDuration err=%d", res )
       
   179     return res;
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CVtCtlVideoCall::GetCallState
       
   184 // Gets call state
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 TInt CVtCtlVideoCall::GetCallState( 
       
   188     MVtCtlCallControl::TVtCtlState& aState )
       
   189     {
       
   190     __VTPRINTENTER( "CVtCtlVideoCall.GetCallState" )
       
   191     RMobileCall::TMobileCallStatus status;
       
   192     aState = iCallInfo.iStatus;    
       
   193     const TInt res( iCall->GetMobileCallStatus( status ) );
       
   194     
       
   195     // update internal state only if differs from previous state
       
   196     if ( res == KErrNone &&
       
   197          CVtCtlCallStatusMonitor::IsLegalNewState( 
       
   198             status, iMobileCallInfo.iStatus ) )
       
   199         {
       
   200         // update 1) internal values, and
       
   201         iMobileCallInfo.iStatus = status;        
       
   202         iCallInfo.iPreviousStatus = iCallInfo.iStatus;
       
   203         iCallInfo.iStatus = CVtCtlCallStatusMonitor::MapState( status );
       
   204 
       
   205         // 2) return value
       
   206         aState = iCallInfo.iStatus;                    
       
   207         }
       
   208     __VTPRINTEXITR( "CVtCtlVideoCall.GetCallState err=%d", res )
       
   209     return res;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CVtCtlVideoCall::HandleCallStatusChangeL
       
   214 // Handles status change
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CVtCtlVideoCall::HandleCallStatusChangeL( 
       
   218     TVtCtlSessionId ,
       
   219     MVtCtlCallControl::TVtCtlState aStatus,
       
   220     MVtCtlCallControl::TVtCtlState aPreviousStatus )
       
   221     {
       
   222     __VTPRINTENTER( "CVtCtlVideoCall.HandleCallStatusChangeL" )
       
   223     // If monitor has received outdated notification ignore the event.
       
   224     // This may happen if call status has asked from ETel and there
       
   225     // are still old completed status notifications that are not handled.
       
   226     // => contradition between internal status in this object and one 
       
   227     //    received from ststus monitor. Ignore it.
       
   228     if ( aStatus > iCallInfo.iStatus || aStatus == MVtCtlCallControl::EIdle )
       
   229         {
       
   230         iCallInfo.iPreviousStatus = iCallInfo.iStatus;
       
   231         iCallInfo.iStatus = aStatus;
       
   232 
       
   233         iObserver.HandleCallStatusChangeL( 
       
   234             iCallInfo.iId, 
       
   235             aStatus,
       
   236             aPreviousStatus );
       
   237         }
       
   238     __VTPRINTEXIT( "CVtCtlVideoCall.HandleCallStatusChangeL" )
       
   239     }
       
   240 #pragma CTC ENDSKIP
       
   241 //  End of File  
       
   242