callcontinuity/vcc/src/cvcctransferprovider.cpp
changeset 0 a4daefaec16c
child 9 bddb6d4447db
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Takes of call transfer 
       
    15 *                (forwards call transfer requests to SVP or CS transfer 
       
    16 *                provider 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #include "cvcctransferprovider.h"
       
    23 #include "cvccperformer.h"
       
    24 #include "cvccdirector.h" // KVCCImplementationUid
       
    25 #include "rubydebug.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // Symbian constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CVccTransferProvider* CVccTransferProvider::NewL( CVccPerformer* aCall )
       
    34 	{
       
    35   RUBY_DEBUG_BLOCK( "CVccTransferProvider::NewL" );
       
    36 	
       
    37 	CVccTransferProvider* self;
       
    38 	self = new( ELeave ) CVccTransferProvider( aCall );
       
    39 	CleanupStack::PushL( self );
       
    40 	self->ConstructL( );
       
    41 	CleanupStack::Pop( self );
       
    42 	return self;
       
    43 	}
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Destructor
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CVccTransferProvider::~CVccTransferProvider()
       
    50 	{
       
    51 	iObservers.Close();
       
    52 	}
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CVccTransferProvider::CVccTransferProvider
       
    56 // C++ default constructor can NOT contain any code, that might leave.
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CVccTransferProvider::CVccTransferProvider(CVccPerformer* aCall )
       
    60     : iPerfCall( aCall )
       
    61     {
       
    62     RUBY_DEBUG_BLOCK( "CVccDtmfProvider::CVccDtmfProvider" );		
       
    63     
       
    64     
       
    65     }
       
    66 		
       
    67 // ---------------------------------------------------------------------------
       
    68 // 2nd phase constructor
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CVccTransferProvider::ConstructL( )
       
    72 	 {
       
    73      RUBY_DEBUG_BLOCK( "CVccTransferProvider::ConstructL" );
       
    74      iCallTransferProvider = iPerfCall->PrimaryCall()->TransferProviderL(*this);
       
    75      iCallTransferProvider->AddObserverL(*this);
       
    76      }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CVccTransferProvider::AttendedTransfer
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 TInt CVccTransferProvider::AttendedTransfer( MCCPCall& aTransferTargetCall )
       
    83     {
       
    84     RUBY_DEBUG_BLOCK( "CVccTransferProvider::AttendedTransfer" );
       
    85     MCCPCall* target = &aTransferTargetCall;
       
    86     if ( target )
       
    87         {
       
    88         if ( KVCCImplementationUid == target->Uid() )
       
    89             {
       
    90             RUBY_DEBUG0( "CVccTransferProvider::AttendedTransfer - Target call Plugin Uid matches VCC Plugin Uid" );
       
    91             CVccPerformer* targetCall = static_cast< CVccPerformer* >(&aTransferTargetCall);
       
    92             target = targetCall->PrimaryCall();
       
    93             }
       
    94         }
       
    95     return iCallTransferProvider->AttendedTransfer( *target );
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CVccTransferProvider::AttendedTransfer
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 TInt CVccTransferProvider::AttendedTransfer( const TDesC& aTransferTarget )
       
   103 	 {
       
   104 	 RUBY_DEBUG_BLOCK( "CVccTransferProvider::AttendedTransfer" );    
       
   105 	 return iCallTransferProvider->AttendedTransfer( aTransferTarget );
       
   106 	 }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CVccTransferProvider::UnattendedTransfer
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 TInt CVccTransferProvider::UnattendedTransfer( const TDesC& aTransferTarget )
       
   113 	 {
       
   114 	 RUBY_DEBUG_BLOCK( "CVccTransferProvider::UnattendedTransfer" );
       
   115      return iCallTransferProvider->UnattendedTransfer( aTransferTarget );
       
   116      }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CVccTransferProvider::AcceptTransfer
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 TInt CVccTransferProvider::AcceptTransfer( const TBool aAccept )
       
   123 	 {
       
   124 	 RUBY_DEBUG_BLOCK( "CVccTransferProvider::AcceptTransfer" );
       
   125      return iCallTransferProvider->AcceptTransfer( aAccept );
       
   126      
       
   127      }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // CVccTransferProvider::TransferTarget()
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 const TDesC& CVccTransferProvider::TransferTarget() const
       
   134 	 {
       
   135 	 RUBY_DEBUG_BLOCK( "CVccTransferProvider::TransferTarget" );
       
   136 	 return iCallTransferProvider->TransferTarget( );
       
   137 	 }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CVccTransferProvider::AddObserverL
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CVccTransferProvider::AddObserverL( const MCCPTransferObserver& aObserver )
       
   144 	 {
       
   145 	 RUBY_DEBUG_BLOCK( "CVccTransferProvider::AddObserverL" );
       
   146 	 iObservers.InsertInAddressOrderL( &aObserver );
       
   147 	 }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CVccTransferProvider::RemoveObserver
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 TInt CVccTransferProvider::RemoveObserver( const MCCPTransferObserver& aObserver )
       
   154 	 {
       
   155 	 RUBY_DEBUG_BLOCK( "CVccTransferProvider::RemoveObserver" );
       
   156 	 TInt res = iObservers.Find( &aObserver );
       
   157 	    if ( res != KErrNotFound )
       
   158 	        {
       
   159 	        iObservers.Remove( res );
       
   160 	        res = KErrNone;
       
   161 	        }
       
   162 	 return res;	
       
   163      }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // CVccTransferProvider::TransferEventOccurred
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CVccTransferProvider::TransferEventOccurred( 
       
   170                 const MCCPTransferObserver::TCCPTransferEvent aEvent )
       
   171     {
       
   172     RUBY_DEBUG_BLOCK( "CVccTransferProvider::TransferEventOccurred" );
       
   173     for ( TInt i = 0; i < iObservers.Count(); i++ )
       
   174        {
       
   175        iObservers[i]->TransferEventOccurred( aEvent );
       
   176        }   
       
   177 
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CVccTransferProvider::UpdateL
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CVccTransferProvider::UpdateL()
       
   185     {
       
   186     RUBY_DEBUG_BLOCK( "CVccTransferProvider::UpdateL" );
       
   187     iCallTransferProvider->RemoveObserver(*this);
       
   188     iCallTransferProvider = iPerfCall->PrimaryCall()->TransferProviderL(*this);
       
   189     iCallTransferProvider->AddObserverL(*this);
       
   190     }
       
   191