Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

166 lines
4.9 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. handlers.h
  7. Prototypes for the various handlers
  8. FILE HISTORY:
  9. */
  10. #ifndef _HANDLERS_H
  11. #define _HANDLERS_H
  12. #ifndef _BASEHAND_H
  13. #include "basehand.h"
  14. #endif
  15. #ifndef _QUERYOBJ_H
  16. #include "queryobj.h"
  17. #endif
  18. #ifndef _PROPPAGE_H
  19. #include "proppage.h"
  20. #endif
  21. typedef CArray<int, int> CVirtualIndexArray;
  22. /*---------------------------------------------------------------------------
  23. Class: ThreadHandler
  24. This is an abstract base class that anyone who wants to run a
  25. background thread needs to implement (if they use the hidden window
  26. mechanism that is).
  27. This is the class that does all of the background thread management.
  28. Author: kennt
  29. ---------------------------------------------------------------------------*/
  30. class ThreadHandler :
  31. public ITFSThreadHandler
  32. {
  33. public:
  34. ThreadHandler();
  35. ~ThreadHandler();
  36. DeclareIUnknownMembers(IMPL)
  37. // Derived classes should implement this
  38. DeclareITFSThreadHandlerMembers(PURE)
  39. // Thread management functions
  40. BOOL StartBackgroundThread(ITFSNode * pNode, HWND hWndHidden, ITFSQueryObject *pQuery);
  41. void WaitForThreadToExit();
  42. void ReleaseThreadHandler();
  43. protected:
  44. // override for custom thread creation
  45. virtual CBackgroundThread* CreateThreadObject();
  46. SPITFSQueryObject m_spQuery;
  47. SPITFSNode m_spNode;
  48. HWND m_hwndHidden; // handle to window to post to
  49. UINT m_uMsgBase;
  50. HANDLE m_hThread;
  51. long m_cRef;
  52. };
  53. typedef CList <CPropertyPageHolderBase *, CPropertyPageHolderBase *> CPropSheetListBase;
  54. /*---------------------------------------------------------------------------
  55. Class: CHandler
  56. ---------------------------------------------------------------------------*/
  57. class CHandler :
  58. public CBaseHandler,
  59. public CBaseResultHandler
  60. {
  61. public:
  62. CHandler(ITFSComponentData *pTFSCompData);
  63. virtual ~CHandler();
  64. DeclareIUnknownMembers(IMPL)
  65. virtual HRESULT OnExpand(ITFSNode *, LPDATAOBJECT, DWORD, LPARAM, LPARAM) { m_bExpanded = TRUE; return hrOK; }
  66. void Lock();
  67. void Unlock();
  68. BOOL IsLocked() { return m_nLockCount > 0;}
  69. OVERRIDE_NodeHandler_UserNotify();
  70. OVERRIDE_NodeHandler_DestroyHandler()
  71. { return DestroyPropSheets(); }
  72. OVERRIDE_ResultHandler_UserResultNotify();
  73. OVERRIDE_ResultHandler_DestroyResultHandler()
  74. { return DestroyPropSheets(); }
  75. // public helpers
  76. int HasPropSheetsOpen();
  77. HRESULT GetOpenPropSheet(int nIndex, CPropertyPageHolderBase ** ppPropSheet);
  78. virtual HRESULT OnRefresh(ITFSNode *, LPDATAOBJECT, DWORD, LPARAM, LPARAM);
  79. protected:
  80. HRESULT BuildSelectedItemList(ITFSComponent * pComponent, CTFSNodeList * plistSelectedItems);
  81. HRESULT BuildVirtualSelectedItemList(ITFSComponent * pComponent, CVirtualIndexArray * parraySelectedItems);
  82. HRESULT RemovePropSheet(CPropertyPageHolderBase * pPageHolder);
  83. HRESULT AddPropSheet(CPropertyPageHolderBase * pPageHolder);
  84. HRESULT DestroyPropSheets();
  85. public:
  86. int m_nState; // for general purpose finite state machine implementation
  87. DWORD m_dwErr; // for general purpose error handling
  88. LONG m_nLockCount; // keeps track if a node has been locked (e.g. to spin a thread, etc.)
  89. BOOL m_bExpanded; // whether or not this node has been expanded yet
  90. protected:
  91. LONG m_cRef;
  92. CPropSheetListBase m_listPropSheets;
  93. };
  94. /*---------------------------------------------------------------------------
  95. Class: CMTHander
  96. ---------------------------------------------------------------------------*/
  97. class CMTHandler :
  98. public CHandler,
  99. public ThreadHandler
  100. {
  101. public:
  102. CMTHandler(ITFSComponentData *pTFSCompData);
  103. virtual ~CMTHandler();
  104. DeclareIUnknownMembers(IMPL)
  105. STDMETHOD (DestroyHandler) (ITFSNode *pNode);
  106. virtual HRESULT OnExpand(ITFSNode *, LPDATAOBJECT, DWORD, LPARAM, LPARAM);
  107. // query creation - override to create a user-specific query object
  108. virtual ITFSQueryObject* OnCreateQuery(ITFSNode *pNode) = 0;
  109. virtual HRESULT OnRefresh(ITFSNode *, LPDATAOBJECT, DWORD, LPARAM, LPARAM);
  110. protected:
  111. virtual int GetImageIndex(BOOL bOpenIndex) { return -1; }
  112. // the next 3 functions are background thread notification callbacks
  113. // these override the ThreadHandler::OnNotifyXXX functions
  114. DeclareITFSThreadHandlerMembers(IMPL)
  115. virtual void OnChangeState(ITFSNode * pNode) {}
  116. virtual void OnHaveData(ITFSNode * pParentNode, ITFSNode * pNode) = 0;
  117. virtual void OnHaveData(ITFSNode * pParentNode, LPARAM Data, LPARAM Type) { };
  118. virtual void OnError(DWORD dwErr) { m_dwErr = dwErr; }
  119. protected:
  120. LONG m_cRef;
  121. private:
  122. // friend class CHiddenWnd; // to get OnThreadNotification()
  123. };
  124. #endif _HANDLERS_H