17 |
17 |
18 #include "mussesseioninformationapi.h" |
18 #include "mussesseioninformationapi.h" |
19 #include "mustsypropertymonitor.h" |
19 #include "mustsypropertymonitor.h" |
20 #include "muscallconferencemonitor.h" |
20 #include "muscallconferencemonitor.h" |
21 #include "muscallmonitor.h" |
21 #include "muscallmonitor.h" |
22 #include "musvoipcallmonitor.h" |
|
23 #include "muslogger.h" |
22 #include "muslogger.h" |
24 #include "musfactorysettings.h" |
23 #include "mussettings.h" |
25 |
24 #include "musclirmonitor.h" |
26 |
25 |
|
26 #include <etel.h> |
27 #include <e32property.h> |
27 #include <e32property.h> |
28 #include <mmtsy_names.h> |
28 #include <mmtsy_names.h> |
29 #include <ctsydomainpskeys.h> |
29 #include <ctsydomainpskeys.h> |
30 |
30 |
31 |
31 |
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 // Symbian two-phase constructor. |
33 // Symbian two-phase constructor. |
34 // ----------------------------------------------------------------------------- |
34 // ----------------------------------------------------------------------------- |
35 // |
35 // |
36 CMusTsyPropertyMonitor* CMusTsyPropertyMonitor::NewL( RMobilePhone& aPhone, |
36 CMusTsyPropertyMonitor* CMusTsyPropertyMonitor::NewL( RMobilePhone& aPhone ) |
37 MMusCallStateObserver& aCallStateObserver ) |
|
38 { |
37 { |
39 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::NewL" ) |
38 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::NewL" ) |
40 CMusTsyPropertyMonitor* self = new (ELeave) CMusTsyPropertyMonitor( aPhone, aCallStateObserver ); |
39 CMusTsyPropertyMonitor* self = new (ELeave) CMusTsyPropertyMonitor(aPhone); |
41 CleanupStack::PushL( self ); |
40 CleanupStack::PushL( self ); |
42 self->ConstructL(); |
41 self->ConstructL(); |
43 CleanupStack::Pop( self ); |
42 CleanupStack::Pop( self ); |
44 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::NewL" ) |
43 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::NewL" ) |
45 return self; |
44 return self; |
100 { |
104 { |
101 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::RunL" ) |
105 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::RunL" ) |
102 // subscribe , so that we dont miss any events. |
106 // subscribe , so that we dont miss any events. |
103 iPropertyEvent.Subscribe( iStatus ); |
107 iPropertyEvent.Subscribe( iStatus ); |
104 SetActive(); |
108 SetActive(); |
105 TPSCTsyCallState callState = EPSCTsyCallStateUninitialized; |
109 TInt value = EPSCTsyCallStateUninitialized; |
106 User::LeaveIfError(iPropertyEvent.Get( (TInt&)callState )); |
110 User::LeaveIfError(iPropertyEvent.Get( value )); |
107 TPSCTsyCallType callType = EPSCTsyCallTypeUninitialized; |
111 MUS_LOG1( "mus: [MUSAO] iTsyCallMonitor->CallState = %d",value ) |
108 User::LeaveIfError(RProperty::Get(KPSUidCtsyCallInformation,KCTsyCallType, |
112 switch(value) |
109 (TInt&)callType)); |
|
110 MUS_LOG1( "mus: [MUSAO] iTsyCallMonitor->CallState = %d",callState ) |
|
111 switch(callState) |
|
112 { |
113 { |
113 case EPSCTsyCallStateNone: |
114 case EPSCTsyCallStateNone: |
114 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateNone" ) |
|
115 SetStateL(NMusSessionInformationApi::ENoCall); |
115 SetStateL(NMusSessionInformationApi::ENoCall); |
116 // Sometimes disconnected call goes stright to this state |
116 // Sometimes disconnected call goes stright to this state |
117 // so we have to call this function to remove call monitors. |
117 // so we have to call this function to remove call monitors. |
118 MonitorCallL( callState,callType); |
118 RemoveAllCallMonitor(); |
119 break; |
119 break; |
120 case EPSCTsyCallStateDisconnecting: |
120 case EPSCTsyCallStateDisconnecting: |
121 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateDisconnecting" ) |
121 case EPSCTsyCallStateAnswering: |
122 MonitorCallL( callState,callType); |
122 case EPSCTsyCallStateConnected: |
123 break; |
123 case EPSCTsyCallStateHold: |
124 case EPSCTsyCallStateAnswering: |
124 // in all above states if multible call exist then |
125 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateAnswering" ) |
125 // we have to find all the calls state and do accordingly. |
126 MonitorCallL( callState,callType); |
126 MonitorCallL(); |
127 break; |
|
128 case EPSCTsyCallStateConnected: |
|
129 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateConnected" ) |
|
130 MonitorCallL( callState,callType); |
|
131 break; |
|
132 case EPSCTsyCallStateHold: |
|
133 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateHold" ) |
|
134 SetStateL(NMusSessionInformationApi::ECallHold); |
|
135 break; |
127 break; |
136 default: |
128 default: |
137 MUS_LOG( "mus: [MUSAO] Undesired CallState " ) |
129 MUS_LOG( "mus: [MUSAO] Undesired CallState " ) |
138 break; |
130 break; |
139 } |
131 } |
320 // No point of reporting it . |
318 // No point of reporting it . |
321 } |
319 } |
322 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::SetStateL" ) |
320 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::SetStateL" ) |
323 } |
321 } |
324 |
322 |
|
323 |
325 // ----------------------------------------------------------------------------- |
324 // ----------------------------------------------------------------------------- |
326 // CMusTsyPropertyMonitor::MonitorCallL() |
325 // CMusTsyPropertyMonitor::MonitorCallL() |
327 // Decides which call monitor (CS,VOIP etc ) has to be called. |
326 // Monitors the call and if needed adds/removes call monitor. |
328 // ----------------------------------------------------------------------------- |
327 // ----------------------------------------------------------------------------- |
329 // |
328 // |
330 void CMusTsyPropertyMonitor::MonitorCallL( const TPSCTsyCallState& aCallState, |
329 void CMusTsyPropertyMonitor::MonitorCallL() |
331 const TPSCTsyCallType& aCallType) |
|
332 { |
|
333 MUS_LOG( "mus: [MUSAO] -> CCMusTsyPropertyMonitor::MonitorCallL" ) |
|
334 switch( aCallType ) |
|
335 { |
|
336 case EPSCTsyCallTypeUninitialized: |
|
337 case EPSCTsyCallTypeNone: |
|
338 case EPSCTsyCallTypeFax: |
|
339 case EPSCTsyCallTypeData: |
|
340 case EPSCTsyCallTypeHSCSD: |
|
341 case EPSCTsyCallTypeH324Multimedia: |
|
342 break;// dont care |
|
343 case EPSCTsyCallTypeCSVoice: |
|
344 MonitorCSCallL(); |
|
345 break; |
|
346 case EPSCTsyCallTypeVoIP: |
|
347 { |
|
348 // if error occured when reading factory setting key |
|
349 // behave default ie all calls supported. |
|
350 TBool supported = ETrue; |
|
351 TRAP_IGNORE( supported = MusFactorySettings::IsSupportedL( aCallType ) ) |
|
352 if( supported) |
|
353 { |
|
354 MonitorVoipCallL( aCallState ); |
|
355 } |
|
356 break; |
|
357 } |
|
358 default: |
|
359 break; |
|
360 } |
|
361 // Check now for multimediasharing call criteria. |
|
362 CheckCallCriteriaL(); |
|
363 MUS_LOG( "mus: [MUSAO] <- CCMusTsyPropertyMonitor::MonitorCallL" ) |
|
364 } |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CMusTsyPropertyMonitor::MonitorCSCallL() |
|
367 // Monitors the CS call and if needed adds/removes call monitor. |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CMusTsyPropertyMonitor::MonitorCSCallL() |
|
371 { |
330 { |
372 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::MonitorCallL") |
331 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::MonitorCallL") |
373 TInt callCount; |
332 TInt callCount; |
374 iLine.EnumerateCall(callCount); |
333 iLine.EnumerateCall(callCount); |
375 MUS_LOG1( "mus: [MUSAO] -> callCount = %d",callCount) |
334 MUS_LOG1( "mus: [MUSAO] -> callCount = %d",callCount) |
388 else if(callInfo.iStatus == RCall::EStatusConnected || |
347 else if(callInfo.iStatus == RCall::EStatusConnected || |
389 callInfo.iStatus == RCall::EStatusAnswering) |
348 callInfo.iStatus == RCall::EStatusAnswering) |
390 { |
349 { |
391 AddCallMonitorL(callInfo.iCallName); |
350 AddCallMonitorL(callInfo.iCallName); |
392 } |
351 } |
393 } |
352 } |
|
353 // Sometimes when call get disconnected then call object disappears.So |
|
354 // check the call state or open the call , if there is an error or undesired |
|
355 // call state , remove that callmonitor from array. |
|
356 RemoveUnUsedCallMonitors(); |
|
357 |
|
358 if(iCallMonitorArray.Count() > 1) |
|
359 { |
|
360 // it is already multicall so atleast one should be hold. |
|
361 // so set the state first to hold |
|
362 SetStateL(NMusSessionInformationApi::ECallHold); |
|
363 // still we dont know here about conference state so |
|
364 // let the conference call monitor decide . |
|
365 iConferenceMonitor->SetStateL(); |
|
366 } |
394 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::MonitorCallL") |
367 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::MonitorCallL") |
395 } |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // CMusTsyPropertyMonitor::MonitorVoipCallL() |
|
399 // Monitors the voip call and if needed adds/removes call monitor. |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 void CMusTsyPropertyMonitor::MonitorVoipCallL( const TPSCTsyCallState& aCallState) |
|
403 { |
|
404 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::MonitorVoipCallL") |
|
405 // TODO : Call Name should be read from covergence api [CCE/CCH] |
|
406 // which is not available as of now 22-Dec-2008 |
|
407 TName callName(_L("Voip 1")); |
|
408 switch(aCallState) |
|
409 { |
|
410 case EPSCTsyCallStateDisconnecting: |
|
411 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateDisconnecting" ) |
|
412 RemoveVoipCallMonitor(callName); |
|
413 break; |
|
414 case EPSCTsyCallStateAnswering: |
|
415 case EPSCTsyCallStateConnected: |
|
416 MUS_LOG( "mus: [MUSAO] EPSCTsyCallStateAnswering/EPSCTsyCallStateConnected" ) |
|
417 AddVoipCallMonitorL(callName); |
|
418 break; |
|
419 default: |
|
420 break; |
|
421 } |
|
422 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::MonitorVoipCallL") |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CMusTsyPropertyMonitor::AddVoipCallMonitorL( TName aCallName ) |
|
427 // Adds new voip call monitor if the call is not monitored already. |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 void CMusTsyPropertyMonitor::AddVoipCallMonitorL(TName& aCallName) |
|
431 { |
|
432 MUS_LOG_TDESC( "mus: [MUSAO] -> CMusTsyPropertyMonitor::AddCallMonitorL"\ |
|
433 ,aCallName ) |
|
434 TBool isCallExist = EFalse; |
|
435 for ( TInt i = 0; i < iVoipCallMonitorArray.Count() && !isCallExist; i++ ) |
|
436 { |
|
437 if( iVoipCallMonitorArray[i]->IsEqual( aCallName ) ) |
|
438 { |
|
439 isCallExist = ETrue; |
|
440 } |
|
441 } |
|
442 MUS_LOG1( "mus: [MUSAO] Call Exist = %d ",isCallExist ) |
|
443 if( !isCallExist ) |
|
444 { |
|
445 CMusVoipCallMonitor* callMonitor = |
|
446 CMusVoipCallMonitor::NewL( aCallName, iCallStateObserver ); |
|
447 CleanupStack::PushL( callMonitor ); |
|
448 iVoipCallMonitorArray.AppendL( callMonitor ); |
|
449 CleanupStack::Pop( callMonitor ); |
|
450 } |
|
451 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::AddCallMonitorL" ) |
|
452 } |
|
453 |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // CMusTsyPropertyMonitor::RemoveCallEventMonitorL( TName aCallName ) |
|
457 // Remove the Call Monitor if it exist in array. |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 void CMusTsyPropertyMonitor::RemoveVoipCallMonitor( TName& aCallName ) |
|
461 { |
|
462 MUS_LOG_TDESC( "mus: [MUSAO] -> CMusTsyPropertyMonitor::RemoveCallMonitor " |
|
463 ,aCallName ) |
|
464 for ( TInt i = 0; i < iVoipCallMonitorArray.Count(); i++ ) |
|
465 { |
|
466 if( iVoipCallMonitorArray[i]->IsEqual( aCallName ) ) |
|
467 { |
|
468 delete iVoipCallMonitorArray[i]; |
|
469 iVoipCallMonitorArray.Remove(i); |
|
470 break; |
|
471 } |
|
472 } |
|
473 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::RemoveCallMonitor" ) |
|
474 } |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors |
|
478 // Remove all voip call monitors |
|
479 // ----------------------------------------------------------------------------- |
|
480 // |
|
481 void CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors( ) |
|
482 { |
|
483 MUS_LOG( "mus: [MUSAO] -> CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors ") |
|
484 iVoipCallMonitorArray.ResetAndDestroy(); |
|
485 iVoipCallMonitorArray.Close(); |
|
486 MUS_LOG( "mus: [MUSAO] <- CMusTsyPropertyMonitor::RemoveAllVoipCallMonitors" ) |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CMusTsyPropertyMonitor::CheckCallCriteria |
|
491 // Checks the Multimediasharing call criterias |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void CMusTsyPropertyMonitor::CheckCallCriteriaL() |
|
495 { |
|
496 TInt csCall = iCallMonitorArray.Count(); |
|
497 TInt voipCall = iVoipCallMonitorArray.Count(); |
|
498 switch( csCall ) |
|
499 { |
|
500 case 0 : |
|
501 { |
|
502 switch( voipCall ) |
|
503 { |
|
504 /* No cs call or voip call */ |
|
505 case 0 : |
|
506 { |
|
507 User::LeaveIfError( |
|
508 RProperty::Set( NMusSessionInformationApi::KCategoryUid, |
|
509 NMusSessionInformationApi::KMusCallEvent, |
|
510 0 )); |
|
511 SetStateL(NMusSessionInformationApi::ENoCall); |
|
512 break; |
|
513 } |
|
514 /* No cs call but one voip call */ |
|
515 case 1 : |
|
516 { |
|
517 iVoipCallMonitorArray[0]-> |
|
518 SetStateL(NMusSessionInformationApi::ECallConnected); |
|
519 break; |
|
520 } |
|
521 /* No cs call but more than one voip call */ |
|
522 default: SetStateL(NMusSessionInformationApi::ECallHold); |
|
523 break; |
|
524 } |
|
525 break; |
|
526 } |
|
527 case 1 : |
|
528 { |
|
529 switch( voipCall ) |
|
530 { |
|
531 /* One cs call but no voip call */ |
|
532 case 0 : break;// Will be handled by cs call monitors. |
|
533 /* One cs call and one or more voip calls */ |
|
534 default : SetStateL(NMusSessionInformationApi::ECallHold); |
|
535 break; |
|
536 } |
|
537 break; |
|
538 } |
|
539 default: // 2 or more CS calls |
|
540 { |
|
541 /* Sometimes when call get disconnected then call object disappears.So |
|
542 * check the call state or open the call , if there is an error or undesired |
|
543 * call state , remove that callmonitor from array. |
|
544 */ |
|
545 RemoveUnUsedCallMonitors(); |
|
546 |
|
547 /* It is already multicall so atleast one should be under hold. |
|
548 * so set the state first to hold and then let the conference |
|
549 * monitor decide the conference state. |
|
550 */ |
|
551 SetStateL(NMusSessionInformationApi::ECallHold); |
|
552 |
|
553 /* Still we dont know here about conference state so |
|
554 * let the conference call monitor decide . |
|
555 */ |
|
556 iConferenceMonitor->SetStateL(); |
|
557 break; |
|
558 } |
|
559 } |
|
560 } |
368 } |
561 |
369 |
562 |
370 |
563 // ----------------------------------------------------------------------------- |
371 // ----------------------------------------------------------------------------- |
564 // CMusTsyPropertyMonitor::CallStatusL() |
372 // CMusTsyPropertyMonitor::CallStatusL() |