--- a/mmsharing/mmshengine/src/musengtelephoneutils.cpp Fri Mar 12 15:42:21 2010 +0200
+++ b/mmsharing/mmshengine/src/musengtelephoneutils.cpp Mon Mar 15 12:40:08 2010 +0200
@@ -20,6 +20,7 @@
#include "musengtelephoneutils.h"
#include "musengaudioroutingobserver.h"
#include "musengmcesession.h"
+#include "musengvolumechangeobserver.h"
#include "muslogger.h"
// SYSTEM
@@ -30,7 +31,6 @@
#include <CPhCltCommandHandler.h> // for CPhCltCommandHandler
-
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
@@ -71,6 +71,12 @@
}
}
+ if ( iNotifier )
+ {
+ iNotifier->StopListening();
+ delete iNotifier;
+ }
+
delete iRepository;
delete iTelephonyAudioRouting;
MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::~CMusEngTelephoneUtils()" )
@@ -158,9 +164,17 @@
CTelephonyAudioRouting::ELoudspeaker );
}
-
+// -----------------------------------------------------------------------------
+// Returns locally cached the CS call volume level.
// -----------------------------------------------------------------------------
-// Gets the CS call volume level.
+//
+TInt CMusEngTelephoneUtils::GetVolume() const
+ {
+ return iCurrentVolume;
+ }
+
+// -----------------------------------------------------------------------------
+// Gets the CS call volume level from central repository.
// Leaves if error occurs when accessing central repository.
// -----------------------------------------------------------------------------
//
@@ -190,8 +204,8 @@
void CMusEngTelephoneUtils::SetVolumeL( TInt aVolume )
{
TInt newVolume = ValidateVolume( aVolume );
-
- if ( GetVolumeL() != newVolume )
+ MUS_LOG1( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetVolumeL(), %d", newVolume )
+ if ( iCurrentVolume != newVolume )
{
if ( IsLoudSpeakerEnabled() )
{
@@ -203,6 +217,7 @@
User::LeaveIfError( iRepository->Set( KTelIncallEarVolume,
newVolume ) );
}
+ iCurrentVolume = newVolume;
}
}
@@ -257,7 +272,16 @@
{
iAudioRoutingObserver = aObserver;
}
-
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
+void CMusEngTelephoneUtils::SetVolumeChangeObserver(
+ MMusEngVolumeChangeObserver* aObserver )
+ {
+ iVolumeObserver = aObserver;
+ }
// -----------------------------------------------------------------------------
//
@@ -323,7 +347,9 @@
{
iAudioRoutingObserver->AudioRoutingChanged( EFalse );
}
-
+
+ UpdateCurrentVolume(ETrue);
+
MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::OutputChanged()" )
}
@@ -338,22 +364,27 @@
{
MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetOutputComplete()" )
- if ( aError == KErrNone && iAudioRoutingObserver )
+ if ( aError == KErrNone )
{
- // If audio routing api didn't shown note and show dialog mode is on,
- // we know that this completion is for such setoutput call for which
- // we need to show the note. Show note mode is turned off only in that
- // case.
- TBool dialogShownByUs( EFalse );
- TBool dialogShownByAudioRouting( EFalse );
- aError = iTelephonyAudioRouting->GetShowNote( dialogShownByAudioRouting );
- if ( aError == KErrNone && !dialogShownByAudioRouting && iShowDialog )
+ if ( iAudioRoutingObserver )
{
- dialogShownByUs = iShowDialog;
- iShowDialog = EFalse;
+ // If audio routing api didn't shown note and show dialog mode is on,
+ // we know that this completion is for such setoutput call for which
+ // we need to show the note. Show note mode is turned off only in that
+ // case.
+ TBool dialogShownByUs( EFalse );
+ TBool dialogShownByAudioRouting( EFalse );
+ aError = iTelephonyAudioRouting->GetShowNote( dialogShownByAudioRouting );
+ if ( aError == KErrNone && !dialogShownByAudioRouting && iShowDialog )
+ {
+ dialogShownByUs = iShowDialog;
+ iShowDialog = EFalse;
+ }
+
+ iAudioRoutingObserver->AudioRoutingChanged( dialogShownByUs );
}
- iAudioRoutingObserver->AudioRoutingChanged( dialogShownByUs );
+ UpdateCurrentVolume(ETrue);
}
MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::SetOutputComplete()" )
@@ -364,6 +395,24 @@
//
// -----------------------------------------------------------------------------
//
+void CMusEngTelephoneUtils::UpdateCurrentVolume( TBool aAudioRouteChanged )
+ {
+ TInt volume(0);
+ TRAPD(error, volume = GetVolumeL() );
+ if( (KErrNone == error) && (iCurrentVolume != volume) )
+ {
+ iCurrentVolume = volume;
+ if ( iVolumeObserver )
+ {
+ iVolumeObserver->VolumeChanged( volume, aAudioRouteChanged );
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+//
CMusEngTelephoneUtils::CMusEngTelephoneUtils()
: CActive( CActive::EPriorityStandard )
{
@@ -381,7 +430,10 @@
// Volume control
iRepository = CRepository::NewL( KCRUidInCallVolume );
-
+
+ iNotifier = CCenRepNotifyHandler::NewL( *this, *iRepository );
+ iNotifier->StartListeningL();
+
// Audio routing control
iTelephonyAudioRouting = CTelephonyAudioRouting::NewL( *this );
@@ -390,7 +442,9 @@
// Phone
MUS_LOG( "mus: [ENGINE] Use static DLL" )
iPhoneCommandHandler = CPhCltCommandHandler::NewL();
-
+
+ iCurrentVolume = GetVolumeL();
+
CActiveScheduler::Add( this );
MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::ConstructL()" )
@@ -439,3 +493,41 @@
}
+// ---------------------------------------------------------------------------
+// CMusEngTelephoneUtils::HandleNotifyGeneric
+// ---------------------------------------------------------------------------
+//
+void CMusEngTelephoneUtils::HandleNotifyGeneric( TUint32 aId )
+ {
+ MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::HandleNotifyGeneric()" )
+ TInt error = KErrArgument;
+ TInt volume = 0;
+ if ( KTelIncallEarVolume == aId )
+ {
+ error = iRepository->Get( KTelIncallEarVolume, volume );
+ MUS_LOG1( "mus: [ENGINE] EAR volume: %d", volume );
+ }
+ else if ( KTelIncallLoudspeakerVolume == aId )
+ {
+ error = iRepository->Get( KTelIncallLoudspeakerVolume, volume );
+ MUS_LOG1( "mus: [ENGINE] Loudspeakers volume: %d", volume );
+ }
+
+ volume = ValidateVolume(volume);
+ if ( (KErrNone == error) && (iCurrentVolume != volume) )
+ {
+ MUS_LOG1( "mus: [ENGINE] volume changed: %d!, notifying UI...", volume )
+ iCurrentVolume = volume;
+ if( iVolumeObserver )
+ {
+ iVolumeObserver->VolumeChanged( volume, EFalse );
+ }
+ }
+ else
+ {
+ MUS_LOG( "mus: [ENGINE] volume hasn't changed!, do nothing..." )
+ }
+
+ MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::HandleNotifyGeneric(), error:%d",
+ error );
+ }