diff -r 33a5d2bbf6fc -r 73a1feb507fb mmshplugins/mmshaoplugin/src/mustsypropertymonitor.cpp --- a/mmshplugins/mmshaoplugin/src/mustsypropertymonitor.cpp Thu Aug 19 09:51:39 2010 +0300 +++ b/mmshplugins/mmshaoplugin/src/mustsypropertymonitor.cpp Tue Aug 31 15:12:07 2010 +0300 @@ -19,11 +19,11 @@ #include "mustsypropertymonitor.h" #include "muscallconferencemonitor.h" #include "muscallmonitor.h" +#include "musvoipcallmonitor.h" #include "muslogger.h" -#include "mussettings.h" -#include "musclirmonitor.h" +#include "musfactorysettings.h" -#include + #include #include #include @@ -33,10 +33,11 @@ // Symbian two-phase constructor. // ----------------------------------------------------------------------------- // -CMusTsyPropertyMonitor* CMusTsyPropertyMonitor::NewL( RMobilePhone& aPhone ) +CMusTsyPropertyMonitor* CMusTsyPropertyMonitor::NewL( RMobilePhone& aPhone, + MMusCallStateObserver& aCallStateObserver ) { MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::NewL" ) - CMusTsyPropertyMonitor* self = new (ELeave) CMusTsyPropertyMonitor(aPhone); + CMusTsyPropertyMonitor* self = new (ELeave) CMusTsyPropertyMonitor( aPhone, aCallStateObserver ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); @@ -53,9 +54,10 @@ { MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::~CMusTsyPropertyMonitor" ) Cancel(); - delete iConferenceMonitor; - delete iClirMonitor; - iCallMonitorArray.ResetAndDestroy(); + delete iConferenceMonitor; + iCallMonitorArray.ResetAndDestroy(); + iCallMonitorArray.Close(); + RemoveAllVoipCallMonitors(); iLine.Close(); MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::~CMusTsyPropertyMonitor" ) } @@ -70,13 +72,7 @@ CActiveScheduler::Add(this); User::LeaveIfError( iLine.Open( iPhone, KMmTsyVoice1LineName() ) ); iConferenceMonitor = CMusCallConferenceMonitor::NewL( - iPhone,iLine,iCallMonitorArray); - - if (MultimediaSharingSettings::PrivacySetting()) - { - iClirMonitor = CMusClirMonitor::NewL(); - } - + iPhone,iLine,iCallMonitorArray); User::LeaveIfError( iPropertyEvent.Attach( KPSUidCtsyCallInformation, KCTsyCallState ) ); @@ -89,8 +85,8 @@ // C++ constructor. // ----------------------------------------------------------------------------- // -CMusTsyPropertyMonitor::CMusTsyPropertyMonitor(RMobilePhone& aPhone) - : CActive( EPriorityNormal ),iPhone(aPhone) +CMusTsyPropertyMonitor::CMusTsyPropertyMonitor(RMobilePhone& aPhone, MMusCallStateObserver& aCallStateObserver ) + : CActive( EPriorityNormal ),iPhone(aPhone), iCallStateObserver ( aCallStateObserver ) { } @@ -106,24 +102,36 @@ // subscribe , so that we dont miss any events. iPropertyEvent.Subscribe( iStatus ); SetActive(); - TInt value = EPSCTsyCallStateUninitialized; - User::LeaveIfError(iPropertyEvent.Get( value )); - MUS_LOG1( "mus: [MUSAO] iTsyCallMonitor->CallState = %d",value ) - switch(value) + TPSCTsyCallState callState = EPSCTsyCallStateUninitialized; + User::LeaveIfError(iPropertyEvent.Get( (TInt&)callState )); + TPSCTsyCallType callType = EPSCTsyCallTypeUninitialized; + User::LeaveIfError(RProperty::Get(KPSUidCtsyCallInformation,KCTsyCallType, + (TInt&)callType)); + MUS_LOG1( "mus: [MUSAO] iTsyCallMonitor->CallState = %d",callState ) + switch(callState) { - case EPSCTsyCallStateNone: + case EPSCTsyCallStateNone: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateNone" ) SetStateL(NMusSessionInformationApi::ENoCall); // Sometimes disconnected call goes stright to this state // so we have to call this function to remove call monitors. - RemoveAllCallMonitor(); - break; - case EPSCTsyCallStateDisconnecting: - case EPSCTsyCallStateAnswering: - case EPSCTsyCallStateConnected: - case EPSCTsyCallStateHold: - // in all above states if multible call exist then - // we have to find all the calls state and do accordingly. - MonitorCallL(); + MonitorCallL( callState,callType); + break; + case EPSCTsyCallStateDisconnecting: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateDisconnecting" ) + MonitorCallL( callState,callType); + break; + case EPSCTsyCallStateAnswering: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateAnswering" ) + MonitorCallL( callState,callType); + break; + case EPSCTsyCallStateConnected: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateConnected" ) + MonitorCallL( callState,callType); + break; + case EPSCTsyCallStateHold: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateHold" ) + SetStateL(NMusSessionInformationApi::ECallHold); break; default: MUS_LOG( "mus: [MUSAO] Undesired CallState " ) @@ -179,19 +187,13 @@ } MUS_LOG1( "mus: [MUSAO] Call Exist = %d ",isCallExist ) if( !isCallExist ) - { - if ( iClirMonitor ) - { - //Start async reading of CLIR from phone settings - iClirMonitor->ReadClir(); - } - + { CMusCallMonitor* callMonitor = CMusCallMonitor::NewL( aCallName, IsPttCallExist() ); CleanupStack::PushL( callMonitor ); iCallMonitorArray.AppendL( callMonitor ); CleanupStack::Pop( callMonitor ); - callMonitor->StartMonitorL(iLine, *this); + callMonitor->StartMonitorL(iLine, *this, iCallStateObserver ); } MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::AddCallMonitorL" ) } @@ -320,13 +322,52 @@ MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::SetStateL" ) } - // ----------------------------------------------------------------------------- // CMusTsyPropertyMonitor::MonitorCallL() -// Monitors the call and if needed adds/removes call monitor. +// Decides which call monitor (CS,VOIP etc ) has to be called. // ----------------------------------------------------------------------------- // -void CMusTsyPropertyMonitor::MonitorCallL() +void CMusTsyPropertyMonitor::MonitorCallL( const TPSCTsyCallState& aCallState, + const TPSCTsyCallType& aCallType) + { + MUS_LOG( "mus: [MUSAO] -> CCMusTsyPropertyMonitor::MonitorCallL" ) + switch( aCallType ) + { + case EPSCTsyCallTypeUninitialized: + case EPSCTsyCallTypeNone: + case EPSCTsyCallTypeFax: + case EPSCTsyCallTypeData: + case EPSCTsyCallTypeHSCSD: + case EPSCTsyCallTypeH324Multimedia: + break;// dont care + case EPSCTsyCallTypeCSVoice: + MonitorCSCallL(); + break; + case EPSCTsyCallTypeVoIP: + { + // if error occured when reading factory setting key + // behave default ie all calls supported. + TBool supported = ETrue; + TRAP_IGNORE( supported = MusFactorySettings::IsSupportedL( aCallType ) ) + if( supported) + { + MonitorVoipCallL( aCallState ); + } + break; + } + default: + break; + } + // Check now for multimediasharing call criteria. + CheckCallCriteriaL(); + MUS_LOG( "mus: [MUSAO] <- CCMusTsyPropertyMonitor::MonitorCallL" ) + } +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::MonitorCSCallL() +// Monitors the CS call and if needed adds/removes call monitor. +// ----------------------------------------------------------------------------- +// +void CMusTsyPropertyMonitor::MonitorCSCallL() { MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::MonitorCallL") TInt callCount; @@ -349,22 +390,173 @@ { AddCallMonitorL(callInfo.iCallName); } - } - // Sometimes when call get disconnected then call object disappears.So - // check the call state or open the call , if there is an error or undesired - // call state , remove that callmonitor from array. - RemoveUnUsedCallMonitors(); + } + MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::MonitorCallL") + } - if(iCallMonitorArray.Count() > 1) +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::MonitorVoipCallL() +// Monitors the voip call and if needed adds/removes call monitor. +// ----------------------------------------------------------------------------- +// +void CMusTsyPropertyMonitor::MonitorVoipCallL( const TPSCTsyCallState& aCallState) + { + MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::MonitorVoipCallL") + // TODO : Call Name should be read from covergence api [CCE/CCH] + // which is not available as of now 22-Dec-2008 + TName callName(_L("Voip 1")); + switch(aCallState) + { + case EPSCTsyCallStateDisconnecting: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateDisconnecting" ) + RemoveVoipCallMonitor(callName); + break; + case EPSCTsyCallStateAnswering: + case EPSCTsyCallStateConnected: + MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateAnswering/EPSCTsyCallStateConnected" ) + AddVoipCallMonitorL(callName); + break; + default: + break; + } + MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::MonitorVoipCallL") + } + +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::AddVoipCallMonitorL( TName aCallName ) +// Adds new voip call monitor if the call is not monitored already. +// ----------------------------------------------------------------------------- +// +void CMusTsyPropertyMonitor::AddVoipCallMonitorL(TName& aCallName) + { + MUS_LOG_TDESC( "mus: [MUSAO] -> CMusTsyPropertyMonitor::AddCallMonitorL"\ + ,aCallName ) + TBool isCallExist = EFalse; + for ( TInt i = 0; i < iVoipCallMonitorArray.Count() && !isCallExist; i++ ) + { + if( iVoipCallMonitorArray[i]->IsEqual( aCallName ) ) + { + isCallExist = ETrue; + } + } + MUS_LOG1( "mus: [MUSAO] Call Exist = %d ",isCallExist ) + if( !isCallExist ) { - // it is already multicall so atleast one should be hold. - // so set the state first to hold - SetStateL(NMusSessionInformationApi::ECallHold); - // still we dont know here about conference state so - // let the conference call monitor decide . - iConferenceMonitor->SetStateL(); + CMusVoipCallMonitor* callMonitor = + CMusVoipCallMonitor::NewL( aCallName, iCallStateObserver ); + CleanupStack::PushL( callMonitor ); + iVoipCallMonitorArray.AppendL( callMonitor ); + CleanupStack::Pop( callMonitor ); + } + MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::AddCallMonitorL" ) + } + + +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::RemoveCallEventMonitorL( TName aCallName ) +// Remove the Call Monitor if it exist in array. +// ----------------------------------------------------------------------------- +// +void CMusTsyPropertyMonitor::RemoveVoipCallMonitor( TName& aCallName ) + { + MUS_LOG_TDESC( "mus: [MUSAO] -> CMusTsyPropertyMonitor::RemoveCallMonitor " + ,aCallName ) + for ( TInt i = 0; i < iVoipCallMonitorArray.Count(); i++ ) + { + if( iVoipCallMonitorArray[i]->IsEqual( aCallName ) ) + { + delete iVoipCallMonitorArray[i]; + iVoipCallMonitorArray.Remove(i); + break; + } } - MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::MonitorCallL") + MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::RemoveCallMonitor" ) + } + +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors +// Remove all voip call monitors +// ----------------------------------------------------------------------------- +// +void CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors( ) + { + MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors ") + iVoipCallMonitorArray.ResetAndDestroy(); + iVoipCallMonitorArray.Close(); + MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors" ) + } + +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::CheckCallCriteria +// Checks the Multimediasharing call criterias +// ----------------------------------------------------------------------------- +// +void CMusTsyPropertyMonitor::CheckCallCriteriaL() + { + TInt csCall = iCallMonitorArray.Count(); + TInt voipCall = iVoipCallMonitorArray.Count(); + switch( csCall ) + { + case 0 : + { + switch( voipCall ) + { + /* No cs call or voip call */ + case 0 : + { + User::LeaveIfError( + RProperty::Set( NMusSessionInformationApi::KCategoryUid, + NMusSessionInformationApi::KMusCallEvent, + 0 )); + SetStateL(NMusSessionInformationApi::ENoCall); + break; + } + /* No cs call but one voip call */ + case 1 : + { + iVoipCallMonitorArray[0]-> + SetStateL(NMusSessionInformationApi::ECallConnected); + break; + } + /* No cs call but more than one voip call */ + default: SetStateL(NMusSessionInformationApi::ECallHold); + break; + } + break; + } + case 1 : + { + switch( voipCall ) + { + /* One cs call but no voip call */ + case 0 : break;// Will be handled by cs call monitors. + /* One cs call and one or more voip calls */ + default : SetStateL(NMusSessionInformationApi::ECallHold); + break; + } + break; + } + default: // 2 or more CS calls + { + /* Sometimes when call get disconnected then call object disappears.So + * check the call state or open the call , if there is an error or undesired + * call state , remove that callmonitor from array. + */ + RemoveUnUsedCallMonitors(); + + /* It is already multicall so atleast one should be under hold. + * so set the state first to hold and then let the conference + * monitor decide the conference state. + */ + SetStateL(NMusSessionInformationApi::ECallHold); + + /* Still we dont know here about conference state so + * let the conference call monitor decide . + */ + iConferenceMonitor->SetStateL(); + break; + } + } } @@ -449,4 +641,41 @@ MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::NotifyCallStateChanged" ) } + + + +// ----------------------------------------------------------------------------- +// CMusTsyPropertyMonitor::IsDataReadyL +// ----------------------------------------------------------------------------- +// +TBool CMusTsyPropertyMonitor::IsDataReadyL() + { + MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::IsDataReadyL" ) + + TBool dataReady = EFalse; + TInt csCall = iCallMonitorArray.Count(); + TInt voipCall = iVoipCallMonitorArray.Count(); + + // In case of Conference Notify that data is ready. + if ( iConferenceMonitor->GetConfStatus() != RMobileConferenceCall::EConferenceIdle ) + { + MUS_LOG( "mus: [MUSAO] Conference CASE" ) + dataReady = ETrue; + } + else if ( csCall == 1 && !voipCall ) + { + MUS_LOG( "mus: [MUSAO] CS CALL" ) + dataReady = iCallMonitorArray[0]->IsDataReadyL(); + } + else if ( voipCall == 1 && !csCall ) + { + MUS_LOG( "mus: [MUSAO] VOIP CALL" ) + dataReady = iVoipCallMonitorArray[0]->IsDataReadyL(); + } + + MUS_LOG1( "mus: [MUSAO] <- CMusTsyPropertyMonitor::IsDataReadyL = %d",dataReady) + return dataReady; + } + // End of file +