ctelephonymonitor.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include <Etel3rdParty.h>
  2. #include "ctelephonymonitor.h"
  3. CTelephonyMonitor::CTelephonyMonitor( MTelephonyStatusObserver& aObserver, CTelephony* aTelephony ) :
  4. CActive( EPriorityStandard )
  5. ,iLineStatusPkg( iLineStatus )
  6. ,iTelephonyStatusObserver( aObserver )
  7. ,iTelephony(aTelephony)
  8. ,iRemotePartyInfoV1Pckg( iRemotePartyInfoV1 )
  9. ,iCallSelectionV1Pckg( iCallSelectionV1 )
  10. ,iCallInfoV1Pckg( iCallInfoV1 )
  11. {
  12. CActiveScheduler::Add( this );
  13. }
  14. CTelephonyMonitor::~CTelephonyMonitor() {
  15. Cancel();
  16. }
  17. void CTelephonyMonitor::RunL() {
  18. if ( iStatus == KErrNone ) {
  19. if( iLineStatus.iStatus == CTelephony::EStatusDialling )
  20. {
  21. iTelephonyStatusObserver.TelephonyStatusChangedL(
  22. iLineStatus.iStatus, GetNumber() );
  23. }
  24. else if( iLineStatus.iStatus == CTelephony::EStatusRinging )
  25. {
  26. iTelephonyStatusObserver.TelephonyStatusChangedL(
  27. iLineStatus.iStatus, GetNumber() );
  28. }
  29. else
  30. {
  31. iTelephonyStatusObserver.TelephonyStatusChangedL(
  32. iLineStatus.iStatus, _L("") );
  33. }
  34. StartListening();
  35. } else {
  36. iTelephonyStatusObserver.ErrorOccuredL( iStatus.Int() );
  37. }
  38. }
  39. CTelephony::TTelNumber CTelephonyMonitor::GetNumber() {
  40. iCallSelectionV1.iLine = CTelephony::EVoiceLine;
  41. iCallSelectionV1.iSelect = CTelephony::EInProgressCall;
  42. iTelephony->GetCallInfo( iCallSelectionV1Pckg, iCallInfoV1Pckg, iRemotePartyInfoV1Pckg );
  43. CTelephony::TTelNumber telNumber;
  44. if( iRemotePartyInfoV1.iRemoteIdStatus == CTelephony::ERemoteIdentityAvailable ) {
  45. if( iRemotePartyInfoV1.iRemoteNumber.iTelNumber.Length() > 0 ) {
  46. telNumber = iRemotePartyInfoV1.iRemoteNumber.iTelNumber;
  47. }
  48. }
  49. if( iCallInfoV1.iDialledParty.iTelNumber.Length() > 0 )
  50. {
  51. telNumber = iCallInfoV1.iDialledParty.iTelNumber;
  52. }
  53. return telNumber;
  54. }
  55. void CTelephonyMonitor::DoCancel() {
  56. iTelephony->CancelAsync( CTelephony::EVoiceLineStatusChangeCancel );
  57. }
  58. void CTelephonyMonitor::StartListening() {
  59. Cancel();
  60. iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPkg );
  61. SetActive();
  62. }