chxavactivewatcher.h
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:2k
源码类别:

Symbian

开发平台:

Visual C++

  1. /************************************************************************
  2.  * chxavactivewatcher.h
  3.  * --------------------
  4.  *
  5.  * Synopsis:
  6.  *
  7.  * base class for classes that request active object
  8.  * event notification from system services
  9.  *
  10.  *
  11.  *
  12.  * (c) 1995-2003 RealNetworks, Inc. Patents pending. All rights reserved.
  13.  *
  14.  ************************************************************************/ 
  15. #ifndef _chxavactivewatcher_h_
  16. #define _chxavactivewatcher_h_
  17. // Include from this project...
  18. #include "chxavcommand.h"
  19. #include "chxavactivecompletiondispatch.h"
  20. #include "chxavcallback.h"
  21. // class CHXAvActiveWatcher
  22. class CHXAvActiveWatcher
  23. {
  24. protected:
  25. // ctor and dtor
  26.     CHXAvActiveWatcher();
  27.     virtual ~CHXAvActiveWatcher();
  28.     void BaseConstructL(TInt activePriority = CActive::EPriorityStandard);
  29. private:
  30. // disallow assignment and copy
  31.     CHXAvActiveWatcher(const CHXAvActiveWatcher& rhs);
  32.     CHXAvActiveWatcher& operator=(const CHXAvActiveWatcher& rhs);
  33. public:
  34. // methods
  35.     void SetEventActionL(const CHXAvCommand& cmd);
  36.     void SetNotificationDelay(TUint msDelay);
  37.     void WatchForNextEvent();
  38.     void StartWatching();
  39.     void StopWatching();
  40.     bool IsWatching() const;
  41. protected:
  42. // implementation
  43.     virtual void OnEvent(TInt status);
  44.     virtual void OnCancelWatch(TInt status);
  45.     virtual void ForwardEvent();
  46.     virtual void DoIssueRequest(const CHXAvActiveCmplPtr& spActive) = 0;
  47.     virtual void DoCancelRequest(const CHXAvActiveCmplPtr& spActive) = 0;
  48. private:
  49. // data
  50.     CHXAvActiveCmplPtr m_spWatchObject;
  51.     bool m_bKeepWatching;
  52.     CHXAvCommandPtr m_spEventHandler;
  53.     CHXAvCallback          m_cbFowardEvent;
  54.     TUint               m_msForwardEventDelay;
  55. };
  56. ////////////////////////////////////////////
  57. // set the handler action to execute upon filesystem event
  58. inline
  59. void CHXAvActiveWatcher::SetEventActionL(const CHXAvCommand& cmd)
  60. {
  61.     m_spEventHandler = cmd.CloneL();
  62. }
  63. ////////////////////////////////////////////
  64. //
  65. inline
  66. bool CHXAvActiveWatcher::IsWatching() const
  67. {
  68.     return m_spWatchObject->IsActive() || m_cbFowardEvent.IsPending();
  69. }
  70. ////////////////////////////////////////////
  71. //
  72. inline
  73. void CHXAvActiveWatcher::SetNotificationDelay(TUint msDelay)
  74. {
  75.     m_msForwardEventDelay = msDelay;
  76. }
  77. #endif // _chxavactivewatcher_h_