2
0

DelayRuner.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. ============================================================================
  3. Name : CDelayRuner.cpp
  4. Author : R. Drutsky
  5. Version : 1.0
  6. Copyright : Copyright (c) 2010 Soft Industry
  7. Description : CCDelayRuner implementation
  8. ============================================================================
  9. */
  10. #include "DelayRuner.h"
  11. #include "zrtp_iface_system.h"
  12. void zrtp_internal_delete_task_from_list(zrtp_stream_t* ctx, zrtp_retry_task_t* ztask);
  13. CDelayRuner::CDelayRuner() :
  14. CActive(EPriorityLow) // Standard priority
  15. {
  16. }
  17. CDelayRuner* CDelayRuner::NewLC()
  18. {
  19. CDelayRuner* self = new (ELeave) CDelayRuner();
  20. CleanupStack::PushL(self);
  21. self->ConstructL();
  22. return self;
  23. }
  24. CDelayRuner* CDelayRuner::NewL()
  25. {
  26. CDelayRuner* self = CDelayRuner::NewLC();
  27. CleanupStack::Pop(); // self;
  28. return self;
  29. }
  30. void CDelayRuner::ConstructL()
  31. {
  32. User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
  33. CActiveScheduler::Add(this); // Add to scheduler
  34. }
  35. CDelayRuner::~CDelayRuner()
  36. {
  37. Cancel(); // Cancel any request, if outstanding
  38. iTimer.Close(); // Destroy the RTimer object
  39. // Delete instance variables if any
  40. }
  41. void CDelayRuner::DoCancel()
  42. {
  43. iTimer.Cancel();
  44. }
  45. void CDelayRuner::StartL(zrtp_stream_t *ctx, zrtp_retry_task_t* ztask)
  46. {
  47. Cancel(); // Cancel any request, just to be sure
  48. //iState = EUninitialized;
  49. iCtx = ctx;
  50. iZTask = ztask;
  51. iTimer.After(iStatus, ztask->timeout * 1000); // Set for later
  52. SetActive(); // Tell scheduler a request is active
  53. }
  54. void CDelayRuner::RunL()
  55. {
  56. if (iStatus == KErrNone)
  57. {
  58. // Do something useful
  59. iZTask->_is_busy = 1 ; // may be we don't need this
  60. (iZTask->callback)(iCtx,iZTask);
  61. iZTask->_is_busy = 0 ; // may be we don't need this
  62. }
  63. zrtp_internal_delete_task_from_list(iCtx,iZTask);
  64. }
  65. TInt CDelayRuner::RunError(TInt aError)
  66. {
  67. return aError;
  68. }