mmshplugins/mmshaoplugin/src/muscallmonitor.cpp
changeset 0 f0cf47e981f9
child 32 73a1feb507fb
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     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, MMusTsyPropertyObserver& aObserver)
       
    93     {
       
    94     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::StartMonitorL" )
       
    95     if(IsMonitored())User::Leave(KErrAlreadyExists);    
       
    96     User::LeaveIfError( iCall.OpenExistingCall( aLine, iCallName ) );        
       
    97     iCallStatusMonitor = CMusCallStatusMonitor::NewL( iCall, aObserver );
       
    98     iCallEventMonitor = CMusCallEventMonitor::NewL( iCall, aObserver );
       
    99     
       
   100     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::StartMonitorL" )
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CMusCallMonitor::StopMonitor()
       
   108     {
       
   109     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::StopMonitorL" )    
       
   110     delete iCallStatusMonitor;
       
   111     iCallStatusMonitor=NULL;
       
   112     delete iCallEventMonitor;
       
   113     iCallEventMonitor=NULL;   
       
   114     iCall.Close();  
       
   115     MUS_LOG( "mus: [MUSAO]  <- CMusCallMonitor::StopMonitorL" )
       
   116     }
       
   117 
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 TBool CMusCallMonitor::IsEqual(TName& aName)
       
   124     {
       
   125     MUS_LOG( "mus: [MUSAO]  -> CMusCallMonitor::IsEqual" )
       
   126     MUS_LOG_TDESC( "mus: [MUSAO]  -> aName : ", aName );
       
   127     MUS_LOG_TDESC( "mus: [MUSAO]  -> iCallName : ", iCallName );
       
   128     TBool val = EFalse ;    
       
   129     val = ( aName == iCallName );    
       
   130     MUS_LOG1( "mus: [MUSAO]  <- CMusCallMonitor::IsEqual = %d",val )
       
   131     return val;
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 const TName CMusCallMonitor::Name()
       
   139     {
       
   140     MUS_LOG( "mus: [MUSAO]  <-> CMusCallMonitor::Name" )    
       
   141     MUS_LOG_TDESC( "mus: iCallName : ", iCallName );
       
   142     return iCallName;
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 TBool CMusCallMonitor::IsMonitored()
       
   150     {
       
   151     MUS_LOG( "mus: [MUSAO]  <-> CMusCallMonitor::IsMonitored" )        
       
   152     return (iCallStatusMonitor || iCallEventMonitor)
       
   153                             ?ETrue :EFalse;    
       
   154     }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // Sets the call count based on callmonitors.
       
   158 // ETrue to increase. EFalse to decrease. 
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 void CMusCallMonitor::SetCallCountL(TBool aIncrease)
       
   162     {
       
   163     // Get Current Call count
       
   164     TInt callCount = 0;
       
   165     User::LeaveIfError(RProperty::Get( NMusSessionInformationApi::KCategoryUid,
       
   166                             NMusSessionInformationApi::KMusCallCount,callCount));
       
   167     // Increment by one
       
   168     ( aIncrease ) ? callCount++ : callCount--;
       
   169     /* Publish this value through internal mush PS key.So that when
       
   170      * other call events happen , we aware about number of active calls.
       
   171      * Set this first.Once object is created.
       
   172      */
       
   173     User::LeaveIfError(RProperty::Set( NMusSessionInformationApi::KCategoryUid,
       
   174                                            NMusSessionInformationApi::KMusCallCount,
       
   175                                            callCount ));  
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CMusCallMonitor::SetStateL()
       
   180 // Set state of call status monitor and call event monitor
       
   181 // -----------------------------------------------------------------------------
       
   182 //
       
   183 void CMusCallMonitor::SetStateL(NMusSessionInformationApi::TMusCallEvent aVal)
       
   184     {
       
   185     iCallStatusMonitor->SetStateL( aVal );
       
   186     iCallEventMonitor->SetStateL( aVal );
       
   187     }
       
   188 
       
   189 
       
   190 // End of file