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.

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