convergedcallengine/cce/src/cccecallinfomediatorupdater.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2008-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:  Updates call information to mediator clients.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cccecallinfomediatorupdater.h"
       
    20 
       
    21 #include <callinformation.h>
       
    22 #include <MediatorDomainUIDs.h>
       
    23 
       
    24 #include "mccecallinfomediator.h"
       
    25 #include "cccecall.h"
       
    26 #include "mccecallobserver.h"
       
    27 #include "mccecallarray.h"
       
    28 #include "mccecallinfo.h"
       
    29 #include "cccecallinfoconverter.h"
       
    30 #include "cccelogger.h"
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Constructor
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CCCECallInfoMediatorUpdater::CCCECallInfoMediatorUpdater(
       
    39     MCCECallInfoMediator& aMediator,
       
    40     MCCECallArray& aCallArray,
       
    41     CCCECallInfoConverter* aConverter ) :
       
    42     iMediator( aMediator ),
       
    43     iCallArray( aCallArray ),
       
    44     iConverter( aConverter )
       
    45     {
       
    46     }
       
    47 
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // Second phase constructor
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 void CCCECallInfoMediatorUpdater::ConstructL()
       
    54     {
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Gets snapshot of call infos and packs them
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 HBufC8* CCCECallInfoMediatorUpdater::GetSnapShotOfCallInfosL()
       
    62     {
       
    63     CCallInfos* infos = CCallInfos::NewLC();
       
    64             
       
    65     for ( TInt i = 0; i < iCallArray.MaxNumberOfCalls(); i++ )
       
    66         {
       
    67         MCCECallInfo* info = iCallArray.CallInfo( i );
       
    68         AddInfoL( info, *infos );
       
    69         }
       
    70     MCCECallInfo* emergencyInfo = iCallArray.EmergencyCallInfo();
       
    71     AddInfoL( emergencyInfo, *infos );
       
    72     
       
    73     HBufC8* packedInfos = infos->ExternalizeL();
       
    74     CleanupStack::PopAndDestroy( infos );
       
    75     return packedInfos;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // Converts call info to mediator info and adds it to the infos.
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CCCECallInfoMediatorUpdater::AddInfoL( 
       
    83     MCCECallInfo* aInfo, 
       
    84     CCallInfos& aInfos )
       
    85     {
       
    86     if ( aInfo )
       
    87         {
       
    88         // Idle calls are not reported to mediator clients
       
    89         if ( aInfo->State() != CCPCall::EStateIdle )
       
    90             {
       
    91             TCallInfo mediatorInfo = iConverter->Convert( *aInfo );
       
    92             aInfos.AddL( mediatorInfo );
       
    93             }
       
    94         }
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Static constructor
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CCCECallInfoMediatorUpdater* CCCECallInfoMediatorUpdater::NewL(
       
   102     MCCECallInfoMediator& aMediator,
       
   103     MCCECallArray& aCallArray,
       
   104     CCCECallInfoConverter* aConverter )
       
   105     {
       
   106     CCCECallInfoMediatorUpdater* self = 
       
   107         CCCECallInfoMediatorUpdater::NewLC(
       
   108             aMediator, aCallArray, aConverter );
       
   109     CleanupStack::Pop( self );
       
   110     return self;
       
   111     }
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // Static constructor
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 CCCECallInfoMediatorUpdater* CCCECallInfoMediatorUpdater::NewLC(
       
   119     MCCECallInfoMediator& aMediator,
       
   120     MCCECallArray& aCallArray,
       
   121     CCCECallInfoConverter* aConverter )
       
   122     {
       
   123     CCCECallInfoMediatorUpdater* self = 
       
   124         new( ELeave ) CCCECallInfoMediatorUpdater( 
       
   125             aMediator, aCallArray, aConverter );
       
   126     CleanupStack::PushL( self );
       
   127     self->ConstructL();
       
   128     return self;
       
   129     }
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // Destructor
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 CCCECallInfoMediatorUpdater::~CCCECallInfoMediatorUpdater()
       
   137     {
       
   138     delete iConverter;
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // Updates the call infos to mediator clients.
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 void CCCECallInfoMediatorUpdater::UpdateL()
       
   146     {            
       
   147     HBufC8* packedInfos = GetSnapShotOfCallInfosL();
       
   148     iMediator.RaiseEvent( EChangesInCallStates, *packedInfos );
       
   149     
       
   150     delete packedInfos;
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // From base class MMediatorCommandObserver
       
   155 // Handles the command of getting all call infos.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CCCECallInfoMediatorUpdater::MediatorCommandL( 
       
   159     TUid aDomain,
       
   160     TUid aCategory, 
       
   161     TInt aCommandId,
       
   162     TVersion /*aVersion*/, 
       
   163     const TDesC8& /*aData*/ )
       
   164     {
       
   165     CCELOGSTRING( "CCCECallInfoMediatorUpdater::MediatorCommandL(): In" );
       
   166     if ( aDomain != KMediatorTelephonyDomain || 
       
   167          aCategory != KCatCallInformation ||
       
   168          aCommandId != EGetAllCallStates )
       
   169         {
       
   170         User::Leave( KErrArgument );
       
   171         }
       
   172     
       
   173     HBufC8* packedInfos = GetSnapShotOfCallInfosL();
       
   174     iMediator.SendResponse( EGetAllCallStates, *packedInfos );
       
   175     
       
   176     CCELOGSTRING( "CCCECallInfoMediatorUpdater::MediatorCommandL(): Out" );
       
   177     delete packedInfos;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // From base class MMediatorCommandObserver
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CCCECallInfoMediatorUpdater::CancelMediatorCommand( 
       
   185     TUid /*aDomain*/,
       
   186     TUid /*aCategory*/, 
       
   187     TInt /*aCommandId*/ )
       
   188     {
       
   189     
       
   190     }