18 |
18 |
19 // USER |
19 // USER |
20 #include "musengtelephoneutils.h" |
20 #include "musengtelephoneutils.h" |
21 #include "musengaudioroutingobserver.h" |
21 #include "musengaudioroutingobserver.h" |
22 #include "musengmcesession.h" |
22 #include "musengmcesession.h" |
|
23 #include "musengvolumechangeobserver.h" |
23 #include "muslogger.h" |
24 #include "muslogger.h" |
24 |
25 |
25 // SYSTEM |
26 // SYSTEM |
26 #include <centralrepository.h> |
27 #include <centralrepository.h> |
27 #include <telephonydomaincrkeys.h> |
28 #include <telephonydomaincrkeys.h> |
28 #include <e32property.h> |
29 #include <e32property.h> |
29 #include <telephonydomainpskeys.h> |
30 #include <telephonydomainpskeys.h> |
30 #include <CPhCltCommandHandler.h> // for CPhCltCommandHandler |
31 #include <CPhCltCommandHandler.h> // for CPhCltCommandHandler |
31 |
32 |
32 |
33 |
33 |
|
34 // ----------------------------------------------------------------------------- |
34 // ----------------------------------------------------------------------------- |
35 // |
35 // |
36 // ----------------------------------------------------------------------------- |
36 // ----------------------------------------------------------------------------- |
37 // |
37 // |
38 CMusEngTelephoneUtils* CMusEngTelephoneUtils::NewL() |
38 CMusEngTelephoneUtils* CMusEngTelephoneUtils::NewL() |
68 TRAPD( err, DoSetOutputL( iAudioOutputAtStartup ) ); |
68 TRAPD( err, DoSetOutputL( iAudioOutputAtStartup ) ); |
69 MUS_LOG1( "mus: [ENGINE] final route change completed: %d", err ) |
69 MUS_LOG1( "mus: [ENGINE] final route change completed: %d", err ) |
70 err++; |
70 err++; |
71 } |
71 } |
72 } |
72 } |
|
73 |
|
74 if ( iNotifier ) |
|
75 { |
|
76 iNotifier->StopListening(); |
|
77 delete iNotifier; |
|
78 } |
73 |
79 |
74 delete iRepository; |
80 delete iRepository; |
75 delete iTelephonyAudioRouting; |
81 delete iTelephonyAudioRouting; |
76 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::~CMusEngTelephoneUtils()" ) |
82 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::~CMusEngTelephoneUtils()" ) |
77 } |
83 } |
156 { |
162 { |
157 return ( iTelephonyAudioRouting->Output() == |
163 return ( iTelephonyAudioRouting->Output() == |
158 CTelephonyAudioRouting::ELoudspeaker ); |
164 CTelephonyAudioRouting::ELoudspeaker ); |
159 } |
165 } |
160 |
166 |
161 |
167 // ----------------------------------------------------------------------------- |
162 // ----------------------------------------------------------------------------- |
168 // Returns locally cached the CS call volume level. |
163 // Gets the CS call volume level. |
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 TInt CMusEngTelephoneUtils::GetVolume() const |
|
172 { |
|
173 return iCurrentVolume; |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // Gets the CS call volume level from central repository. |
164 // Leaves if error occurs when accessing central repository. |
178 // Leaves if error occurs when accessing central repository. |
165 // ----------------------------------------------------------------------------- |
179 // ----------------------------------------------------------------------------- |
166 // |
180 // |
167 TInt CMusEngTelephoneUtils::GetVolumeL() const |
181 TInt CMusEngTelephoneUtils::GetVolumeL() const |
168 { |
182 { |
188 // ----------------------------------------------------------------------------- |
202 // ----------------------------------------------------------------------------- |
189 // |
203 // |
190 void CMusEngTelephoneUtils::SetVolumeL( TInt aVolume ) |
204 void CMusEngTelephoneUtils::SetVolumeL( TInt aVolume ) |
191 { |
205 { |
192 TInt newVolume = ValidateVolume( aVolume ); |
206 TInt newVolume = ValidateVolume( aVolume ); |
193 |
207 MUS_LOG1( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetVolumeL(), %d", newVolume ) |
194 if ( GetVolumeL() != newVolume ) |
208 if ( iCurrentVolume != newVolume ) |
195 { |
209 { |
196 if ( IsLoudSpeakerEnabled() ) |
210 if ( IsLoudSpeakerEnabled() ) |
197 { |
211 { |
198 User::LeaveIfError( iRepository->Set( KTelIncallLoudspeakerVolume, |
212 User::LeaveIfError( iRepository->Set( KTelIncallLoudspeakerVolume, |
199 newVolume ) ); |
213 newVolume ) ); |
255 void CMusEngTelephoneUtils::SetAudioRoutingObserver( |
270 void CMusEngTelephoneUtils::SetAudioRoutingObserver( |
256 MMusEngAudioRoutingObserver* aObserver ) |
271 MMusEngAudioRoutingObserver* aObserver ) |
257 { |
272 { |
258 iAudioRoutingObserver = aObserver; |
273 iAudioRoutingObserver = aObserver; |
259 } |
274 } |
260 |
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 void CMusEngTelephoneUtils::SetVolumeChangeObserver( |
|
281 MMusEngVolumeChangeObserver* aObserver ) |
|
282 { |
|
283 iVolumeObserver = aObserver; |
|
284 } |
261 |
285 |
262 // ----------------------------------------------------------------------------- |
286 // ----------------------------------------------------------------------------- |
263 // |
287 // |
264 // ----------------------------------------------------------------------------- |
288 // ----------------------------------------------------------------------------- |
265 // |
289 // |
336 CTelephonyAudioRouting& /*aTelephonyAudioRouting*/, |
362 CTelephonyAudioRouting& /*aTelephonyAudioRouting*/, |
337 TInt aError ) |
363 TInt aError ) |
338 { |
364 { |
339 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetOutputComplete()" ) |
365 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetOutputComplete()" ) |
340 |
366 |
341 if ( aError == KErrNone && iAudioRoutingObserver ) |
367 if ( aError == KErrNone ) |
342 { |
368 { |
343 // If audio routing api didn't shown note and show dialog mode is on, |
369 if ( iAudioRoutingObserver ) |
344 // we know that this completion is for such setoutput call for which |
370 { |
345 // we need to show the note. Show note mode is turned off only in that |
371 // If audio routing api didn't shown note and show dialog mode is on, |
346 // case. |
372 // we know that this completion is for such setoutput call for which |
347 TBool dialogShownByUs( EFalse ); |
373 // we need to show the note. Show note mode is turned off only in that |
348 TBool dialogShownByAudioRouting( EFalse ); |
374 // case. |
349 aError = iTelephonyAudioRouting->GetShowNote( dialogShownByAudioRouting ); |
375 TBool dialogShownByUs( EFalse ); |
350 if ( aError == KErrNone && !dialogShownByAudioRouting && iShowDialog ) |
376 TBool dialogShownByAudioRouting( EFalse ); |
351 { |
377 aError = iTelephonyAudioRouting->GetShowNote( dialogShownByAudioRouting ); |
352 dialogShownByUs = iShowDialog; |
378 if ( aError == KErrNone && !dialogShownByAudioRouting && iShowDialog ) |
353 iShowDialog = EFalse; |
379 { |
354 } |
380 dialogShownByUs = iShowDialog; |
355 |
381 iShowDialog = EFalse; |
356 iAudioRoutingObserver->AudioRoutingChanged( dialogShownByUs ); |
382 } |
|
383 |
|
384 iAudioRoutingObserver->AudioRoutingChanged( dialogShownByUs ); |
|
385 } |
|
386 |
|
387 UpdateCurrentVolume(ETrue); |
357 } |
388 } |
358 |
389 |
359 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::SetOutputComplete()" ) |
390 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::SetOutputComplete()" ) |
360 } |
391 } |
361 |
392 |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CMusEngTelephoneUtils::UpdateCurrentVolume( TBool aAudioRouteChanged ) |
|
399 { |
|
400 TInt volume(0); |
|
401 TRAPD(error, volume = GetVolumeL() ); |
|
402 if( (KErrNone == error) && (iCurrentVolume != volume) ) |
|
403 { |
|
404 iCurrentVolume = volume; |
|
405 if ( iVolumeObserver ) |
|
406 { |
|
407 iVolumeObserver->VolumeChanged( volume, aAudioRouteChanged ); |
|
408 } |
|
409 } |
|
410 } |
362 |
411 |
363 // ----------------------------------------------------------------------------- |
412 // ----------------------------------------------------------------------------- |
364 // |
413 // |
365 // ----------------------------------------------------------------------------- |
414 // ----------------------------------------------------------------------------- |
366 // |
415 // |
379 { |
428 { |
380 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::ConstructL()" ) |
429 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::ConstructL()" ) |
381 |
430 |
382 // Volume control |
431 // Volume control |
383 iRepository = CRepository::NewL( KCRUidInCallVolume ); |
432 iRepository = CRepository::NewL( KCRUidInCallVolume ); |
384 |
433 |
|
434 iNotifier = CCenRepNotifyHandler::NewL( *this, *iRepository ); |
|
435 iNotifier->StartListeningL(); |
|
436 |
385 // Audio routing control |
437 // Audio routing control |
386 iTelephonyAudioRouting = CTelephonyAudioRouting::NewL( *this ); |
438 iTelephonyAudioRouting = CTelephonyAudioRouting::NewL( *this ); |
387 |
439 |
388 iAudioOutputAtStartup = iTelephonyAudioRouting->Output(); |
440 iAudioOutputAtStartup = iTelephonyAudioRouting->Output(); |
389 |
441 |
390 // Phone |
442 // Phone |
391 MUS_LOG( "mus: [ENGINE] Use static DLL" ) |
443 MUS_LOG( "mus: [ENGINE] Use static DLL" ) |
392 iPhoneCommandHandler = CPhCltCommandHandler::NewL(); |
444 iPhoneCommandHandler = CPhCltCommandHandler::NewL(); |
393 |
445 |
|
446 iCurrentVolume = GetVolumeL(); |
|
447 |
394 CActiveScheduler::Add( this ); |
448 CActiveScheduler::Add( this ); |
395 |
449 |
396 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::ConstructL()" ) |
450 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::ConstructL()" ) |
397 } |
451 } |
398 |
452 |
437 iTelephonyAudioRouting->SetOutputL( aAudioOutput ); |
491 iTelephonyAudioRouting->SetOutputL( aAudioOutput ); |
438 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::DoSetOutputL()" ) |
492 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::DoSetOutputL()" ) |
439 } |
493 } |
440 |
494 |
441 |
495 |
|
496 // --------------------------------------------------------------------------- |
|
497 // CMusEngTelephoneUtils::HandleNotifyGeneric |
|
498 // --------------------------------------------------------------------------- |
|
499 // |
|
500 void CMusEngTelephoneUtils::HandleNotifyGeneric( TUint32 aId ) |
|
501 { |
|
502 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::HandleNotifyGeneric()" ) |
|
503 TInt error = KErrArgument; |
|
504 TInt volume = 0; |
|
505 if ( KTelIncallEarVolume == aId ) |
|
506 { |
|
507 error = iRepository->Get( KTelIncallEarVolume, volume ); |
|
508 MUS_LOG1( "mus: [ENGINE] EAR volume: %d", volume ); |
|
509 } |
|
510 else if ( KTelIncallLoudspeakerVolume == aId ) |
|
511 { |
|
512 error = iRepository->Get( KTelIncallLoudspeakerVolume, volume ); |
|
513 MUS_LOG1( "mus: [ENGINE] Loudspeakers volume: %d", volume ); |
|
514 } |
|
515 |
|
516 volume = ValidateVolume(volume); |
|
517 if ( (KErrNone == error) && (iCurrentVolume != volume) ) |
|
518 { |
|
519 MUS_LOG1( "mus: [ENGINE] volume changed: %d!, notifying UI...", volume ) |
|
520 iCurrentVolume = volume; |
|
521 if( iVolumeObserver ) |
|
522 { |
|
523 iVolumeObserver->VolumeChanged( volume, EFalse ); |
|
524 } |
|
525 } |
|
526 else |
|
527 { |
|
528 MUS_LOG( "mus: [ENGINE] volume hasn't changed!, do nothing..." ) |
|
529 } |
|
530 |
|
531 MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::HandleNotifyGeneric(), error:%d", |
|
532 error ); |
|
533 } |