mmshplugins/mmshaoplugin/src/muscallmonitor.cpp
changeset 22 496ad160a278
equal deleted inserted replaced
15:ccd8e69b5392 22:496ad160a278
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Monitor that observes the status of the current CS call
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "mussesseioninformationapi.h"
       
    20 #include "muspttcallmonitor.h"
       
    21 #include "muscallmonitor.h"
       
    22 #include "muscallstatusmonitor.h"
       
    23 #include "muscalleventmonitor.h"
       
    24 #include "musresourceproperties.h"
       
    25 #include "muslogger.h"
       
    26 
       
    27 #include <etelmm.h>
       
    28 #include <e32property.h>
       
    29 
       
    30 
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // Symbian two-phase constructor.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CMusCallMonitor* CMusCallMonitor::NewL( TName& aCallName,TBool aPttCallExist )
       
    37     {
       
    38     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::NewL" )
       
    39     CMusCallMonitor* self = new (ELeave) CMusCallMonitor( aPttCallExist );
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL( aCallName );
       
    42     CleanupStack::Pop( self );
       
    43     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::NewL" )
       
    44     return self;
       
    45     }
       
    46 
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // C++ destructor.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CMusCallMonitor::~CMusCallMonitor()
       
    53     {
       
    54     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::~CMusCallMonitor" )
       
    55     delete iCallStatusMonitor;        
       
    56     delete iCallEventMonitor;    
       
    57     iCall.Close();  
       
    58     // callcount decrease by one and if leave happens here mostly 
       
    59     // property Key not exist,so do not care.
       
    60     TRAP_IGNORE(SetCallCountL (EFalse)); 
       
    61     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::~CMusCallMonitor" )
       
    62     }
       
    63 
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // C++ constructor.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CMusCallMonitor::CMusCallMonitor( TBool aPttCallExist ) 
       
    70     :iPttCallExist(aPttCallExist)  
       
    71     {    
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // Symbian second-phase constructor.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void CMusCallMonitor::ConstructL(TName& aCallName)
       
    80     {
       
    81     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::ConstructL" )      
       
    82     iCallName = aCallName;
       
    83     SetCallCountL (ETrue); // increase by one.
       
    84     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::ConstructL" )
       
    85     }
       
    86 
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CMusCallMonitor::StartMonitorL(RMobileLine& aLine, 
       
    93                                     MMusTsyPropertyObserver& aObserver,
       
    94                                     MMusCallStateObserver& aCallStateObserver)
       
    95     {
       
    96     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::StartMonitorL" )
       
    97     if(IsMonitored())User::Leave(KErrAlreadyExists);    
       
    98     User::LeaveIfError( iCall.OpenExistingCall( aLine, iCallName ) );        
       
    99     iCallStatusMonitor = CMusCallStatusMonitor::NewL( iCall, aObserver, aCallStateObserver );
       
   100     iCallEventMonitor = CMusCallEventMonitor::NewL( iCall, aObserver, aCallStateObserver );    
       
   101     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::StartMonitorL" )
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CMusCallMonitor::StopMonitor()
       
   109     {
       
   110     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::StopMonitorL" )    
       
   111     delete iCallStatusMonitor;
       
   112     iCallStatusMonitor=NULL;
       
   113     delete iCallEventMonitor;
       
   114     iCallEventMonitor=NULL;   
       
   115     iCall.Close();  
       
   116     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::StopMonitorL" )
       
   117     }
       
   118 
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TBool CMusCallMonitor::IsEqual(TName& aName)
       
   125     {
       
   126     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::IsEqual" )
       
   127     MUS_LOG_TDESC( "mus: [MUSAO]  -> aName : ", aName );
       
   128     MUS_LOG_TDESC( "mus: [MUSAO]  -> iCallName : ", iCallName );
       
   129     TBool val = EFalse ;    
       
   130     val = ( aName == iCallName );    
       
   131     MUS_LOG1( "mus: [MUSAO]  <- CMusCallMonitor::IsEqual = %d",val )
       
   132     return val;
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 const TName CMusCallMonitor::Name()
       
   140     {
       
   141     MUS_LOG( "mus: [MUSAO]  <-> CMusCallMonitor::Name" )    
       
   142     MUS_LOG_TDESC( "mus: iCallName : ", iCallName );
       
   143     return iCallName;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TBool CMusCallMonitor::IsMonitored()
       
   151     {
       
   152     MUS_LOG( "mus: [MUSAO]  <-> CMusCallMonitor::IsMonitored" )        
       
   153     return (iCallStatusMonitor || iCallEventMonitor)
       
   154                             ?ETrue :EFalse;    
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // Sets the call count based on callmonitors.
       
   159 // ETrue to increase. EFalse to decrease. 
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CMusCallMonitor::SetCallCountL(TBool aIncrease)
       
   163     {
       
   164     // Get Current Call count
       
   165     TInt callCount = 0;
       
   166     User::LeaveIfError(RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   167                             NMusSessionInformationApi::KMusCallCount,callCount));
       
   168     // Increment by one
       
   169     ( aIncrease ) ? callCount++ : callCount--;
       
   170     /* Publish this value through internal mush PS key.So that when
       
   171      * other call events happen , we aware about number of active calls.
       
   172      * Set this first.Once object is created.
       
   173      */
       
   174     User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   175                                            NMusSessionInformationApi::KMusCallCount,
       
   176                                            callCount ));  
       
   177     }
       
   178 
       
   179 // -----------------------------------------------------------------------------
       
   180 // CMusCallMonitor::SetStateL()
       
   181 // Set state of call status monitor and call event monitor
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CMusCallMonitor::SetStateL(NMusSessionInformationApi::TMusCallEvent aVal)
       
   185     {
       
   186     iCallStatusMonitor->SetStateL( aVal );
       
   187     iCallEventMonitor->SetStateL( aVal );
       
   188     }
       
   189 
       
   190 
       
   191 // --------------------------------------------------------------------------------
       
   192 // CMusCallMonitor::IsDataReadyL()
       
   193 // Checks if Data is ready CS Call.
       
   194 // --------------------------------------------------------------------------------
       
   195 
       
   196 TBool CMusCallMonitor::IsDataReadyL()
       
   197     {
       
   198     // Wrapper Function for Monitoring CS Call Data
       
   199     return iCallStatusMonitor->IsDataReadyL();
       
   200     }
       
   201 
       
   202 // End of file
       
   203