ccallterminator.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "ccallterminator.h"
  2. #include <w32std.h>
  3. #include <QDebug>
  4. CCallTerminator::CCallTerminator(MTerminatorObserver& aObserver, CTelephony* aTelephony)
  5. : CActive(EPriorityStandard)
  6. ,iObserver(aObserver)
  7. ,iTelephony(aTelephony)
  8. {
  9. CActiveScheduler::Add( this );
  10. }
  11. CCallTerminator::~CCallTerminator() {
  12. Cancel();
  13. }
  14. void CCallTerminator::Terminate()
  15. {
  16. iTelephony->Hangup(iStatus, iCallId);
  17. SetActive();
  18. }
  19. void CCallTerminator::Reject() {
  20. RWsSession ws;
  21. ws.Connect();
  22. TRawEvent ev1;
  23. ev1.Set(TRawEvent::EKeyDown, EStdKeyNo);
  24. ws.SimulateRawEvent(ev1); // CAPABILITY Req. SwEvent
  25. User::After(1000000);
  26. TRawEvent ev2;
  27. ev2.Set(TRawEvent::EKeyUp, EStdKeyNo);
  28. ws.SimulateRawEvent(ev2); // CAPABILITY Req. SwEvent
  29. ws.Close();
  30. qDebug() << "[CCallTerminator::Rejected]";
  31. iObserver.CallRejectedL( iStatus.Int() );
  32. }
  33. void CCallTerminator::RunL()
  34. {
  35. iObserver.CallTerminatedL( iStatus.Int() );
  36. if(iStatus==KErrNone) {
  37. qDebug() << "Call terminated successfully";
  38. } else {
  39. qDebug() << "[CCallTerminator::RunL()] errore: "<< QString::number(iStatus.Int());
  40. }
  41. }
  42. void CCallTerminator::DoCancel()
  43. {
  44. iTelephony->CancelAsync(CTelephony::EHangupCancel);
  45. }