telutils/telephonyservice/src/ccallinformationimpl.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Provides implementation for CCallInformation -class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <callinformation.h>    //Call Information Mediator API
       
    21 
       
    22 #include "ccallinformationimpl.h"
       
    23 #include "ccallinfoiter.h"
       
    24 #include "mcallinformationobserver.h"
       
    25 #include "telsrvlogger.h"
       
    26 
       
    27 
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // C++ constructor.
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CCallInformationImpl::CCallInformationImpl() : CTelSrvBase( )
       
    35     {
       
    36          
       
    37     }
       
    38 
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Symbian second-phase constructor.
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 void CCallInformationImpl::ConstructL(CMediatorService* aMediatorService)
       
    45     {    
       
    46     CTelSrvBase::BaseConstructL( aMediatorService );    
       
    47     
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Two-phased constructor.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CCallInformationImpl* CCallInformationImpl::NewL()
       
    56     {
       
    57     TSLOGSTRING("CCallInformationImpl::NewL <<");
       
    58     CCallInformationImpl* self = new (ELeave) CCallInformationImpl( );     
       
    59     CleanupStack::PushL( self );
       
    60     
       
    61     CMediatorService* mediatorService = CMediatorService::NewLC( CMediatorService::ECallInfo );    
       
    62     self->ConstructL(mediatorService);    
       
    63         
       
    64     CleanupStack::Pop( 2,self );    
       
    65     TSLOGSTRING("CCallInformationImpl::NewL >>");
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Two-phased constructor for testing purposes.
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CCallInformationImpl* CCallInformationImpl::NewL(CMediatorService* aMediatorService)
       
    74     {        
       
    75     CCallInformationImpl* self = new (ELeave) CCallInformationImpl( );    
       
    76     
       
    77     CleanupStack::PushL( self );
       
    78     self->ConstructL(aMediatorService);
       
    79     CleanupStack::Pop( self );
       
    80     
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // Destructor
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CCallInformationImpl::~CCallInformationImpl()
       
    90     {        
       
    91     delete iInfos;
       
    92     delete iCallIter;       
       
    93     delete iInfosInState;    
       
    94     delete iCallStateIter;    
       
    95     }
       
    96 
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // Saves the observer call information changes.
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CCallInformationImpl::NotifyCallInformationChanges(
       
   103     MCallInformationObserver& aObserver )
       
   104     {
       
   105     TSLOGSTRING("CCallInformationImpl::NotifyCallInformationChanges <<");
       
   106     iObserver = &aObserver;    
       
   107     }
       
   108     
       
   109 // ---------------------------------------------------------------------------
       
   110 // Removes the observer.
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CCallInformationImpl::CancelNotification( )
       
   114     {
       
   115     TSLOGSTRING("CCallInformationImpl::CancelNotification <<");
       
   116     iObserver = NULL;    
       
   117     }
       
   118 
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // From class CTelSrvBase.
       
   122 // A response to a Mediator Service command.
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CCallInformationImpl::DoHandleCommandResponseL( const TDesC8& aData )
       
   126   {
       
   127   TSLOGSTRING("CCallInformationImpl::DoHandleCommandResponseL <<");  
       
   128   iInfos = CCallInfos::NewL();
       
   129   iInfos->InternalizeL( aData );                
       
   130   iCallIter = CCallInfoIter::NewL( *iInfos );
       
   131   
       
   132   TSLOGSTRING("CCallInformationImpl::DoHandleCommandResponseL >>");
       
   133   }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // From class MMediatorServiceObserver
       
   137 // A Mediator Service event.
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 void CCallInformationImpl::DoHandleMediatorEventL( const TDesC8& aData )
       
   141   {  
       
   142   TSLOGSTRING("CCallInformationImpl::DoHandleMediatorEventL <<");  
       
   143   delete iInfos;
       
   144   iInfos = NULL;
       
   145       
       
   146   delete iCallIter;
       
   147   iCallIter = NULL;
       
   148       
       
   149   iInfos = CCallInfos::NewL();
       
   150   iInfos->InternalizeL( aData );      
       
   151   iCallIter = CCallInfoIter::NewL( *iInfos );      
       
   152         
       
   153   if( iObserver )
       
   154       {
       
   155       iObserver->CallInformationChanged();
       
   156       }  
       
   157   TSLOGSTRING("CCallInformationImpl::DoHandleMediatorEventL >>");
       
   158   }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // Returns info about all calls. 
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 CCallInfoIter& CCallInformationImpl::GetCallsL( )
       
   165     {    
       
   166     TSLOGSTRING("CCallInformationImpl::GetCallsL <<");
       
   167     if( !iCallIter )
       
   168         {
       
   169         TSLOGSTRING("CCallInformationImpl::GetCallsL; Leaves with KErrNoMemory");
       
   170         User::Leave( KErrNoMemory ); //memory allocation failed in CommandResponseL or MediatorEventL
       
   171         }
       
   172     
       
   173     TSLOGSTRING("CCallInformationImpl::GetCallsL >>");
       
   174     return *iCallIter;            
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // Returns information whether call in given state exist. 
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 TBool CCallInformationImpl::IsCallInState( CCPCall::TCallState aState ) const
       
   182     {
       
   183     TBool match ( EFalse );
       
   184     
       
   185     const RPointerArray<TCallInfo>& calls = iInfos->CallInfos();
       
   186     TInt count = calls.Count();
       
   187         
       
   188     for( int i = 0; i < count; i++ )
       
   189         {
       
   190         const TCallInfo& call = *calls[i];
       
   191         if( aState == call.CallState() )    
       
   192             {
       
   193             match = ETrue;
       
   194             break;
       
   195             }
       
   196         }           
       
   197     return match;
       
   198     }
       
   199 
       
   200 
       
   201 
       
   202 
       
   203