callcontinuity/vcc/src/cvccconferencecall.cpp
changeset 0 a4daefaec16c
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:   Base class of VCC conference call object
       
    15 *
       
    16 */
       
    17 
       
    18 #include <mccpcscall.h> //CCP API
       
    19 
       
    20 #include "cvccconferencecall.h"
       
    21 #include "cvccperformer.h"
       
    22 #include "cconvergedcallprovider.h"
       
    23 #include "rubydebug.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // C'tor
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CVccConferenceCall::CVccConferenceCall( const TUint32 aServiceId,
       
    32                                    const MCCPConferenceCallObserver& aObserver,
       
    33                                    RVccCallArray& aCallArray )
       
    34 : iServiceId( aServiceId ), 
       
    35   iObserver( const_cast<MCCPConferenceCallObserver*>( &aObserver ) ),
       
    36   iCallArray( aCallArray )
       
    37     {
       
    38     RUBY_DEBUG_BLOCK("CVccConferenceCall::CVccConferenceCall");
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // C'tor
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CVccConferenceCall::CVccConferenceCall( MCCPConferenceCall& aConferenceCall,
       
    46                                    RVccCallArray& aCallArray )
       
    47 : iServiceId( aConferenceCall.ServiceId() ), 
       
    48   iCallArray( aCallArray )
       
    49     {
       
    50     RUBY_DEBUG_BLOCK("CVccConferenceCall::CVccConferenceCall");
       
    51     RUBY_DEBUG0("CVccConferenceCall::CVccConferenceCall2");
       
    52     iConferenceCall = &aConferenceCall;
       
    53     // Get reference to CS plugin
       
    54     CConvergedCallProvider& csProv = iCallArray[0]->CsProvider();
       
    55     iCsProvider = &csProv;
       
    56     }
       
    57 // ---------------------------------------------------------------------------
       
    58 // 2nd phase C'tor
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 void CVccConferenceCall::ConstructL()
       
    62     {
       
    63     RUBY_DEBUG_BLOCKL( "CVccConferenceCall::ConstructL" );
       
    64     
       
    65     __ASSERT_ALWAYS( iCallArray.Count() > 0, User::Leave( KErrArgument ) );
       
    66     
       
    67     // Get reference to CS plugin
       
    68     CConvergedCallProvider& csProv = iCallArray[0]->CsProvider();
       
    69     iCsProvider = &csProv;
       
    70     
       
    71     // Order CS plugin to create new conference
       
    72     iConferenceCall = iCsProvider->NewConferenceL( iServiceId, *this );
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Two phased C'tor
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CVccConferenceCall* CVccConferenceCall::NewL( const TUint32 aServiceId,
       
    80                                    const MCCPConferenceCallObserver& aObserver,
       
    81                                    RVccCallArray& aCallArray )
       
    82     {
       
    83     CVccConferenceCall* self = new( ELeave ) CVccConferenceCall( aServiceId,
       
    84                                                                  aObserver,
       
    85                                                                  aCallArray );
       
    86     CleanupStack::PushL( self );
       
    87     self->ConstructL();
       
    88     CleanupStack::Pop( self );
       
    89     return self;
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // Two phased C'tor
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 CVccConferenceCall* CVccConferenceCall::NewL( MCCPConferenceCall& aConferenceCall, 
       
    97                                     RVccCallArray& aCallArray )
       
    98     {
       
    99     RUBY_DEBUG0("CVccConferenceCall::NewL2");
       
   100         
       
   101     CVccConferenceCall* self = new( ELeave ) CVccConferenceCall( 
       
   102                                                 aConferenceCall,
       
   103                                                 aCallArray );
       
   104     
       
   105     return self;
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // D'tor
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 CVccConferenceCall::~CVccConferenceCall()
       
   113     {
       
   114     RUBY_DEBUG0( "CVccConferenceCall::~CVccConferenceCall() - ENTER" );
       
   115     
       
   116     RUBY_DEBUG0( "CVccConferenceCall::~CVccConferenceCall() - EXIT" );
       
   117     }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // Signals CS plugin that conference is released
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 void CVccConferenceCall::ReleaseConference()
       
   124     {
       
   125     RUBY_DEBUG_BLOCK( "CVccConferenceCall::ReleaseConference" );
       
   126     iCsProvider->ReleaseConferenceCall( *iConferenceCall );
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 //  @see MCCPConferenceCall::ServiceId 
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 TUint32 CVccConferenceCall::ServiceId() const
       
   134     {
       
   135     RUBY_DEBUG_BLOCK("CVccConferenceCall::ServiceId");
       
   136     
       
   137     return iServiceId;
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 //  @see MCCPConferenceCall::HangUp 
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 TInt CVccConferenceCall::HangUp()
       
   145     {
       
   146     RUBY_DEBUG_BLOCK( "CVccConferenceCall::HangUp" );
       
   147     
       
   148     TInt retValue( iConferenceCall->HangUp() );
       
   149     
       
   150     RUBY_DEBUG1( "Error: %d", retValue );
       
   151     
       
   152     return retValue;
       
   153     }
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 //  @see MCCPConferenceCall::Hold 
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 TInt CVccConferenceCall::Hold()
       
   160     {
       
   161     RUBY_DEBUG_BLOCK( "CVccConferenceCall::Hold" );
       
   162 
       
   163     TInt retValue( iConferenceCall->Hold() );
       
   164     
       
   165     RUBY_DEBUG1( "Error: %d", retValue );
       
   166     
       
   167     return retValue;
       
   168     }
       
   169 
       
   170    
       
   171 // ---------------------------------------------------------------------------
       
   172 //  @see MCCPConferenceCall::Resume 
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 TInt CVccConferenceCall::Resume()
       
   176     {
       
   177     RUBY_DEBUG_BLOCK( "CVccConferenceCall::Resume" );
       
   178     
       
   179     TInt retValue(  iConferenceCall->Resume() );
       
   180     
       
   181     RUBY_DEBUG1( "Error: %d", retValue );
       
   182     
       
   183     return retValue;
       
   184     }
       
   185 
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 //  @see MCCPConferenceCall::Swap 
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TInt CVccConferenceCall::Swap()
       
   192     {
       
   193     RUBY_DEBUG_BLOCK( "CVccConferenceCall::Swap" );
       
   194     
       
   195     TInt retValue( iConferenceCall->Swap() );
       
   196     
       
   197     RUBY_DEBUG1( "Error: %d", retValue );
       
   198     
       
   199     return retValue;
       
   200     }
       
   201 
       
   202 
       
   203 // ---------------------------------------------------------------------------
       
   204 //  @see MCCPConferenceCall::AddCallL 
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void CVccConferenceCall::AddCallL( MCCPCall* aCall )
       
   208     {
       
   209     RUBY_DEBUG_BLOCK( "CVccConferenceCall::AddCallL" );
       
   210 
       
   211     // NULL pointer
       
   212     __ASSERT_ALWAYS( aCall, User::Leave( KErrArgument ) );
       
   213     RUBY_DEBUG0( "- Not a NULL pointer" );
       
   214     
       
   215     CVccPerformer* call = static_cast<CVccPerformer*>( aCall );
       
   216 
       
   217     // Tell CS plugin to add the call in conference and add it to the
       
   218     // local conference array
       
   219     iConferenceCall->AddCallL( call->PrimaryCall() );
       
   220         
       
   221     }
       
   222 
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 //  @see MCCPConferenceCall::RemoveCallL 
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CVccConferenceCall::RemoveCallL( MCCPCall* aCall )
       
   229     {
       
   230     RUBY_DEBUG_BLOCK( "CVccConferenceCall::RemoveCallL" );
       
   231     
       
   232     // NULL pointer
       
   233     __ASSERT_ALWAYS( aCall, User::Leave( KErrArgument ) );
       
   234     RUBY_DEBUG0( "- Not a NULL pointer" );
       
   235     
       
   236     CVccPerformer* call = static_cast<CVccPerformer*>( aCall );
       
   237 
       
   238     // Tell CS plugin to remeove call from conference
       
   239     iConferenceCall->RemoveCallL( call->PrimaryCall() );
       
   240     
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 //  @see MCCPConferenceCall::CallCount 
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 TInt CVccConferenceCall::CallCount() const
       
   248     {
       
   249     RUBY_DEBUG_BLOCK( "CVccConferenceCall::CallCount" );
       
   250     
       
   251     return iConferenceCall->CallCount();
       
   252     }
       
   253 
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 //  @see MCCPConferenceCall::GoOneToOneL 
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 void CVccConferenceCall::GoOneToOneL( MCCPCall& aCall )
       
   260     {
       
   261     RUBY_DEBUG_BLOCK( "CVccConferenceCall::GoOneToOneL" );
       
   262     
       
   263     // Find call from conference array
       
   264     CVccPerformer* call = dynamic_cast<CVccPerformer*>( &aCall );
       
   265     
       
   266     // Check that the call was found in conference array
       
   267     __ASSERT_ALWAYS( call, User::Leave( KErrNotFound ) );   
       
   268     
       
   269     // Tell CS plugin to go one-on-one
       
   270     iConferenceCall->GoOneToOneL( *call->PrimaryCall() );
       
   271     }
       
   272 
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 //  @see MCCPConferenceCall::CurrentCallsToConferenceL 
       
   276 // ---------------------------------------------------------------------------
       
   277 //
       
   278 void CVccConferenceCall::CurrentCallsToConferenceL()
       
   279     {
       
   280     RUBY_DEBUG_BLOCK( "CVccConferenceCall::CurrentCallsToConferenceL" );
       
   281     iConferenceCall->CurrentCallsToConferenceL();
       
   282     }
       
   283   
       
   284 // ---------------------------------------------------------------------------
       
   285 //  @see MCCPConferenceCall::AddObserverL 
       
   286 // ---------------------------------------------------------------------------
       
   287 //
       
   288 void CVccConferenceCall::AddObserverL( 
       
   289                                    const MCCPConferenceCallObserver& aObserver )
       
   290     {
       
   291     RUBY_DEBUG_BLOCK( "CVccConferenceCall::AddObserverL" );
       
   292     
       
   293     iObserver = const_cast<MCCPConferenceCallObserver*>( &aObserver );
       
   294     }
       
   295 
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 //  @see MCCPConferenceCall::RemoveObserver 
       
   299 // ---------------------------------------------------------------------------
       
   300 //
       
   301 TInt CVccConferenceCall::RemoveObserver( 
       
   302                                    const MCCPConferenceCallObserver& aObserver )
       
   303     {
       
   304     RUBY_DEBUG_BLOCK( "CVccConferenceCall::RemoveObserver" );
       
   305     
       
   306     TInt retValue( KErrNone );
       
   307     
       
   308     if ( iObserver ==  &aObserver )
       
   309         {
       
   310         iObserver = NULL;
       
   311         }
       
   312     else
       
   313         {
       
   314         retValue = KErrNotFound;
       
   315         }
       
   316     
       
   317     return retValue;
       
   318     }
       
   319 
       
   320 // ---------------------------------------------------------------------------
       
   321 //  @see MCCPConferenceCallObserver::ErrorOccurred 
       
   322 // ---------------------------------------------------------------------------
       
   323 //
       
   324 void CVccConferenceCall::ErrorOccurred( TCCPConferenceCallError aError )
       
   325     {
       
   326     RUBY_DEBUG_BLOCK( "CVccConferenceCall::ErrorOccurred" );
       
   327     RUBY_DEBUG1( "- Error code [%d]", aError );
       
   328     
       
   329     // Tell CCE level that error occurred
       
   330     iObserver->ErrorOccurred( aError );
       
   331     }
       
   332 
       
   333 
       
   334 // ---------------------------------------------------------------------------
       
   335 //  @see MCCPConferenceCallObserver::ConferenceCallCapsChanged 
       
   336 // ---------------------------------------------------------------------------
       
   337 //
       
   338 void CVccConferenceCall::ConferenceCallCapsChanged( 
       
   339     const TCCPConferenceCallCaps aCaps )
       
   340     {
       
   341     RUBY_DEBUG_BLOCK( "CVccConferenceCall::ConferenceCallStateChanged()" );
       
   342     RUBY_DEBUG1( "- Caps = %d", aCaps  );
       
   343     
       
   344     iObserver->ConferenceCallCapsChanged( aCaps );
       
   345     }
       
   346 
       
   347 
       
   348 // ---------------------------------------------------------------------------
       
   349 //  @see MCCPConferenceCallObserver::ConferenceCallStateChanged 
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CVccConferenceCall::ConferenceCallStateChanged( 
       
   353     const TCCPConferenceCallState aState )
       
   354     {
       
   355     RUBY_DEBUG_BLOCK( "CVccConferenceCall::ConferenceCallStateChanged" );
       
   356     RUBY_DEBUG1( "- State = %d", aState );
       
   357     iObserver->ConferenceCallStateChanged( aState );
       
   358     }
       
   359 
       
   360 // ---------------------------------------------------------------------------
       
   361 //  @see MCCPConferenceCallObserver::ConferenceCallEventOccurred 
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 void CVccConferenceCall::ConferenceCallEventOccurred( 
       
   365      const TCCPConferenceCallEvent aEvent, MCCPCall* aReferredCall )
       
   366     {
       
   367     RUBY_DEBUG_BLOCK( "CVccConferenceCall::ConferenceCallEventOccurred" );
       
   368     iObserver->ConferenceCallEventOccurred( aEvent, 
       
   369             MatchPluginToVccCall( aReferredCall ) );
       
   370     }
       
   371 
       
   372 
       
   373 // ---------------------------------------------------------------------------
       
   374 // Search a specific call from call array
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 CVccPerformer* CVccConferenceCall::MatchPluginToVccCall( MCCPCall* aPluginCall )
       
   378     {
       
   379     RUBY_DEBUG_BLOCK( "CVccConferenceCall::FindInCallArray()" );
       
   380     
       
   381     CVccPerformer* call = NULL;
       
   382     
       
   383     if ( aPluginCall )
       
   384         {
       
   385         for ( TInt i = 0; i < iCallArray.Count(); i++ )
       
   386             {
       
   387             // Comparison is made to CVccPerformer and MCCPCall objects
       
   388             // for simplicity sake
       
   389             if ( iCallArray[i]->PrimaryCall() == aPluginCall )
       
   390                 {
       
   391                 RUBY_DEBUG0( "- Call found" );
       
   392                 call = iCallArray[i];
       
   393                 break;
       
   394                 }
       
   395             }
       
   396         }
       
   397     
       
   398     return call;
       
   399     }
       
   400 
       
   401 // ---------------------------------------------------------------------------
       
   402 // Collect all conference participants into array
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 TInt CVccConferenceCall::GetCallArray( RPointerArray<MCCPCall>& aCallArray )
       
   406     {
       
   407     RUBY_DEBUG_BLOCK( "CVccConferenceCall::GetCallArray" );
       
   408     RPointerArray<MCCPCall> pluginCalls;
       
   409     iConferenceCall->GetCallArray( pluginCalls );
       
   410     for( TInt i = 0; i < pluginCalls.Count(); i++ )
       
   411         {
       
   412         aCallArray.Append( MatchPluginToVccCall( pluginCalls[i] ) );
       
   413         }
       
   414         
       
   415     pluginCalls.Close();    
       
   416     return KErrNone;
       
   417     }
       
   418