Source code of Windows XP (NT5)
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.

262 lines
8.9 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. dhcphand.h
  7. Header file for dhcp specific base handler classes and query obj
  8. FILE HISTORY:
  9. */
  10. #ifndef _DHCPHAND_H
  11. #define _DHCPHAND_H
  12. #define DHCP_IP_ADDRESS_INVALID ((DHCP_IP_ADDRESS)0)
  13. #ifndef _HANDLERS_H
  14. #include <handlers.h>
  15. #endif
  16. #ifndef _QUERYOBJ_H
  17. #include <queryobj.h>
  18. #endif
  19. class CClassInfoArray;
  20. class COptionValueEnum;
  21. class CToolbarInfo
  22. {
  23. public:
  24. CToolbarInfo() : fSelected(FALSE) {};
  25. SPITFSNode spNode;
  26. BOOL fSelected;
  27. };
  28. /*---------------------------------------------------------------------------
  29. Class: CHandlerEx
  30. ---------------------------------------------------------------------------*/
  31. class CHandlerEx
  32. {
  33. // Interface
  34. public:
  35. virtual HRESULT InitializeNode(ITFSNode * pNode) = 0;
  36. LPCTSTR GetDisplayName() { return m_strDisplayName; }
  37. void SetDisplayName(LPCTSTR pName) { m_strDisplayName = pName; }
  38. private:
  39. CString m_strDisplayName;
  40. };
  41. /*---------------------------------------------------------------------------
  42. Class: CDhcpHandler
  43. ---------------------------------------------------------------------------*/
  44. class CDhcpHandler :
  45. public CHandler,
  46. public CHandlerEx
  47. {
  48. public:
  49. CDhcpHandler(ITFSComponentData *pCompData)
  50. : CHandler(pCompData),
  51. m_verbDefault(MMC_VERB_OPEN) {};
  52. ~CDhcpHandler() {};
  53. // base handler virtual function over-rides
  54. virtual HRESULT SaveColumns(ITFSComponent *, MMC_COOKIE, LPARAM, LPARAM);
  55. // by default we don't allow nodes to be renamed
  56. OVERRIDE_BaseHandlerNotify_OnRename() { return hrFalse; }
  57. // Toolbar functionality
  58. OVERRIDE_NodeHandler_UserNotify();
  59. OVERRIDE_ResultHandler_UserResultNotify();
  60. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  61. OVERRIDE_BaseResultHandlerNotify_OnResultDelete();
  62. OVERRIDE_BaseResultHandlerNotify_OnResultContextHelp();
  63. // Multi-select functionalty
  64. OVERRIDE_ResultHandler_OnCreateDataObject();
  65. // menu stuff
  66. OVERRIDE_ResultHandler_AddMenuItems();
  67. OVERRIDE_ResultHandler_Command();
  68. HRESULT HandleScopeCommand(MMC_COOKIE cookie, int nCommandID, LPDATAOBJECT pDataObject);
  69. HRESULT HandleScopeMenus(MMC_COOKIE cookie, LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pContextMenuCallback, long * pInsertionAllowed);
  70. // toolbar stuff
  71. virtual HRESULT OnControlbarNotify(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  72. virtual HRESULT OnResultControlbarNotify(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  73. virtual HRESULT OnToolbarButtonClick(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  74. virtual HRESULT OnUpdateToolbarButtons(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  75. void EnableToolbar(LPTOOLBAR pToolbar,
  76. MMCBUTTON rgSnapinButtons[],
  77. int nRgSize,
  78. MMC_BUTTON_STATE ButtonState[],
  79. BOOL bState = TRUE);
  80. void EnableVerbs(IConsoleVerb * pConsoleVerb,
  81. MMC_BUTTON_STATE ButtonState[],
  82. BOOL bEnable[]);
  83. virtual DWORD UpdateStatistics(ITFSNode * pNode) { return 0; }
  84. // any node with taskpads should override this to identify itself
  85. virtual int GetTaskpadIndex() { return 0; }
  86. protected:
  87. HRESULT CreateMultiSelectData(ITFSComponent * pComponent, CDataObject * pObject);
  88. public:
  89. // This is the default verb, by default it is set to MMC_VERB_OPEN
  90. MMC_CONSOLE_VERB m_verbDefault;
  91. };
  92. /*---------------------------------------------------------------------------
  93. Class: CMTDhcpHandler
  94. ---------------------------------------------------------------------------*/
  95. class CMTDhcpHandler :
  96. public CMTHandler,
  97. public CHandlerEx
  98. {
  99. public:
  100. // enumeration for node states, to handle icon changes
  101. typedef enum
  102. {
  103. notLoaded = 0, // initial state, valid only if server never contacted
  104. loading,
  105. loaded,
  106. unableToLoad
  107. } nodeStateType;
  108. CMTDhcpHandler(ITFSComponentData *pCompData)
  109. : CMTHandler(pCompData),
  110. m_verbDefault(MMC_VERB_OPEN),
  111. m_bSelected(FALSE),
  112. m_fSilent(FALSE),
  113. m_fExpandSync(FALSE)
  114. { m_nState = notLoaded; }
  115. ~CMTDhcpHandler() {};
  116. // base handler virtual function over-rides
  117. virtual HRESULT SaveColumns(ITFSComponent *, MMC_COOKIE, LPARAM, LPARAM);
  118. // by default we don't allow nodes to be renamed
  119. OVERRIDE_BaseHandlerNotify_OnRename() { return hrFalse; }
  120. OVERRIDE_BaseHandlerNotify_OnExpandSync();
  121. // base result handler overrides
  122. OVERRIDE_BaseResultHandlerNotify_OnResultRefresh();
  123. OVERRIDE_BaseResultHandlerNotify_OnResultUpdateView();
  124. OVERRIDE_BaseResultHandlerNotify_OnResultSelect();
  125. OVERRIDE_BaseResultHandlerNotify_OnResultContextHelp();
  126. // Toolbar functionality
  127. OVERRIDE_NodeHandler_UserNotify();
  128. OVERRIDE_ResultHandler_UserResultNotify();
  129. // Multi-select functionalty
  130. OVERRIDE_ResultHandler_OnCreateDataObject();
  131. virtual HRESULT OnControlbarNotify(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  132. virtual HRESULT OnResultControlbarNotify(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  133. virtual HRESULT OnToolbarButtonClick(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  134. virtual HRESULT OnUpdateToolbarButtons(ITFSNode * pNode, LPDHCPTOOLBARNOTIFY pToolbarNotify);
  135. // menu stuff
  136. OVERRIDE_ResultHandler_AddMenuItems();
  137. OVERRIDE_ResultHandler_Command();
  138. HRESULT HandleScopeCommand(MMC_COOKIE cookie, int nCommandID, LPDATAOBJECT pDataObject);
  139. HRESULT HandleScopeMenus(MMC_COOKIE cookie, LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK pContextMenuCallback, long * pInsertionAllowed);
  140. void EnableToolbar(LPTOOLBAR pToolbar,
  141. MMCBUTTON rgSnapinButtons[],
  142. int nRgSize,
  143. MMC_BUTTON_STATE ButtonState[],
  144. BOOL Enable[]);
  145. void EnableVerbs(IConsoleVerb * pConsoleVerb,
  146. MMC_BUTTON_STATE ButtonState[],
  147. BOOL bEnable[]);
  148. // for statistics notification
  149. HRESULT OnRefreshStats(ITFSNode * pNode,
  150. LPDATAOBJECT pDataObject,
  151. DWORD dwType,
  152. LPARAM arg,
  153. LPARAM param);
  154. virtual DWORD UpdateStatistics(ITFSNode * pNode) { return 0; }
  155. virtual HRESULT OnRefresh(ITFSNode *, LPDATAOBJECT, DWORD, LPARAM, LPARAM);
  156. HRESULT OnResultUpdateOptions(ITFSComponent * pComponent,
  157. ITFSNode * pNode,
  158. CClassInfoArray * pClassInfoArray,
  159. COptionValueEnum * aEnum[],
  160. int aImages[],
  161. int nCount);
  162. protected:
  163. virtual void GetErrorMessages(CString & strTitle, CString & strBody, IconIdentifier * icon);
  164. virtual void OnChangeState(ITFSNode* pNode);
  165. virtual void OnHaveData(ITFSNode * pParentNode, ITFSNode * pNewNode)
  166. {
  167. if (pNewNode->IsContainer())
  168. {
  169. // assume all the child containers are derived from this class
  170. //((CDHCPMTContainer*)pNode)->SetServer(GetServer());
  171. }
  172. pParentNode->AddChild(pNewNode);
  173. }
  174. void UpdateStandardVerbs(ITFSNode * pToolbar, LONG_PTR dwNodeType);
  175. void SendUpdateToolbar(ITFSNode * pNode, BOOL fSelected);
  176. virtual void UpdateConsoleVerbs(IConsoleVerb * pConsoleVerb, LONG_PTR dwNodeType, BOOL bMultiSelect = FALSE);
  177. virtual void UpdateToolbar(IToolbar * pToolbar, LONG_PTR dwNodeType, BOOL bSelect);
  178. HRESULT CreateMultiSelectData(ITFSComponent * pComponent, CDataObject * pObject);
  179. void ExpandNode(ITFSNode * pNode, BOOL fExpand);
  180. // any node with taskpads should override this to identify itself
  181. virtual int GetTaskpadIndex() { return 0; }
  182. protected:
  183. BOOL m_bSelected;
  184. BOOL m_fSilent;
  185. BOOL m_fExpandSync;
  186. // This is the default verb, by default it is set to MMC_VERB_OPEN
  187. MMC_CONSOLE_VERB m_verbDefault;
  188. };
  189. /*---------------------------------------------------------------------------
  190. Class: CDHCPQueryObj : general purpose base class
  191. ---------------------------------------------------------------------------*/
  192. class CDHCPQueryObj : public CNodeQueryObject
  193. {
  194. public:
  195. CDHCPQueryObj
  196. (
  197. ITFSComponentData * pTFSCompData,
  198. ITFSNodeMgr * pNodeMgr
  199. ) : m_dwErr(0)
  200. {
  201. m_spTFSCompData.Set(pTFSCompData);
  202. m_spNodeMgr.Set(pNodeMgr);
  203. }
  204. CQueueDataListBase & GetQueue() { return m_dataQueue; }
  205. public:
  206. CString m_strServer;
  207. SPITFSComponentData m_spTFSCompData;
  208. SPITFSNodeMgr m_spNodeMgr;
  209. DWORD m_dwErr;
  210. };
  211. #endif _DHCPHAND_H