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.

467 lines
12 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. OptCfg.h
  7. Option configuration pages. The option configuration pages
  8. keep lists off all of the default options for a given class ID.
  9. For the pre-NT5 and default case, the class name is null
  10. indicating no associated class. When there is a class defined,
  11. a CClassTracker object with the class name is created.
  12. Only the advanced page uses CClassTrackers with non-null names.
  13. If there are no non-null class names then the advanced page
  14. will be disabled.
  15. FILE HISTORY:
  16. */
  17. #ifndef _OPTCFG_H
  18. #define _OPTCFG_H
  19. #ifndef _LISTVIEW_H
  20. #include "listview.h"
  21. #endif
  22. #ifndef _CTRLGRP_H
  23. #include <ctrlgrp.h>
  24. #endif
  25. #ifndef _DHCPHAND_H
  26. #include "dhcphand.h"
  27. #endif
  28. #ifndef _CLASSED_H
  29. #include "classed.h"
  30. #endif
  31. #ifndef _CLASSID_H
  32. #include "classmod.h"
  33. #endif
  34. #ifndef _SERVER_H
  35. #include "server.h"
  36. #endif
  37. #if _MSC_VER >= 1000
  38. #pragma once
  39. #endif // _MSC_VER >= 1000
  40. class CDhcpOptionItem;
  41. #define OPTION_STATE_ACTIVE 1
  42. #define OPTION_STATE_INACTIVE 2
  43. #define WM_SELECTOPTION WM_USER + 200
  44. #define WM_SELECTCLASSES WM_USER + 201
  45. // this class builds the correct help map for the given option sheet
  46. class CHelpMap
  47. {
  48. public:
  49. CHelpMap();
  50. ~CHelpMap();
  51. void BuildMap(DWORD pdwParentHelpMap[]);
  52. DWORD * GetMap();
  53. protected:
  54. int CountMap(const DWORD * pdwHelpMap);
  55. void ResetMap();
  56. DWORD * m_pdwHelpMap;
  57. };
  58. // This class tracks a given option to see if it has been modified, etc
  59. class COptionTracker
  60. {
  61. public:
  62. COptionTracker()
  63. {
  64. m_uInitialState = OPTION_STATE_INACTIVE;
  65. m_uCurrentState = OPTION_STATE_INACTIVE;
  66. m_bDirty = FALSE;
  67. m_pOption = NULL;
  68. }
  69. ~COptionTracker()
  70. {
  71. if (m_pOption)
  72. delete m_pOption;
  73. }
  74. UINT GetInitialState() { return m_uInitialState; }
  75. void SetInitialState(UINT uInitialState) { m_uInitialState = uInitialState; }
  76. UINT GetCurrentState() { return m_uCurrentState; }
  77. void SetCurrentState(UINT uCurrentState) { m_uCurrentState = uCurrentState; }
  78. void SetDirty(BOOL bDirty) { m_bDirty = bDirty; }
  79. BOOL IsDirty() { return m_bDirty; }
  80. CDhcpOption * m_pOption;
  81. protected:
  82. UINT m_uInitialState;
  83. UINT m_uCurrentState;
  84. BOOL m_bDirty;
  85. };
  86. typedef CList<COptionTracker *, COptionTracker *> COptionTrackerListBase;
  87. class COptionTrackerList : public COptionTrackerListBase
  88. {
  89. public:
  90. ~COptionTrackerList()
  91. {
  92. // cleanup the list
  93. while (!IsEmpty())
  94. delete RemoveHead();
  95. }
  96. };
  97. // this class tracks the option set for a given User Class ID
  98. class CClassTracker
  99. {
  100. public:
  101. CClassTracker() {};
  102. ~CClassTracker() {};
  103. LPCTSTR GetClassName() { return m_strClassName; }
  104. void SetClassName(LPCTSTR pClassName) { m_strClassName = pClassName; }
  105. public:
  106. CString m_strClassName;
  107. BOOL m_bIsVendor;
  108. COptionTrackerList m_listOptions;
  109. };
  110. typedef CList<CClassTracker *, CClassTracker *> CClassTrackerListBase;
  111. class CClassTrackerList : public CClassTrackerListBase
  112. {
  113. public:
  114. ~CClassTrackerList()
  115. {
  116. // cleanup the list
  117. while (!IsEmpty())
  118. delete RemoveHead();
  119. }
  120. };
  121. // this class tracks the user classes for a vendor option class option set
  122. class CVendorTracker
  123. {
  124. public:
  125. CVendorTracker() {};
  126. ~CVendorTracker() {};
  127. LPCTSTR GetClassName() { return m_strClassName; }
  128. void SetClassName(LPCTSTR pClassName) { m_strClassName = pClassName; }
  129. public:
  130. CString m_strClassName;
  131. BOOL m_bIsVendor;
  132. CClassTrackerList m_listUserClasses;
  133. };
  134. typedef CList<CVendorTracker *, CVendorTracker *> CVendorTrackerListBase;
  135. class CVendorTrackerList : public CVendorTrackerListBase
  136. {
  137. public:
  138. ~CVendorTrackerList()
  139. {
  140. // Cleanup the list
  141. while (!IsEmpty())
  142. delete RemoveHead();
  143. }
  144. };
  145. /////////////////////////////////////////////////////////////////////////////
  146. // COptionsCfgBasic dialog
  147. class COptionsCfgPropPage : public CPropertyPageBase
  148. {
  149. DECLARE_DYNCREATE(COptionsCfgPropPage)
  150. // Construction
  151. public:
  152. COptionsCfgPropPage();
  153. COptionsCfgPropPage(UINT nIDTemplate, UINT nIDCaption = 0);
  154. ~COptionsCfgPropPage();
  155. // Dialog Data
  156. //{{AFX_DATA(COptionsCfgPropPage)
  157. enum { IDD = IDP_OPTION_BASIC };
  158. CMyListCtrl m_listctrlOptions;
  159. //}}AFX_DATA
  160. CImageList m_StateImageList;
  161. ControlGroupSwitcher m_cgsTypes;
  162. CWndHexEdit m_hexData; // Hex Data
  163. void LoadBitmaps();
  164. void InitListCtrl();
  165. void SelectOption(CDhcpOption * pOption);
  166. void SwitchDataEntry(int datatype, int optiontype, BOOL fRouteArray, BOOL bEnable);
  167. void FillDataEntry(CDhcpOption * pOption);
  168. void HandleActivationStringArray();
  169. void HandleActivationIpArray();
  170. void HandleActivationValueArray();
  171. void HandleActivationRouteArray(CDhcpOptionValue *optValue = NULL);
  172. BOOL HandleValueEdit();
  173. void MoveValue(BOOL bValues, BOOL bUp);
  174. // Context Help Support
  175. virtual DWORD * GetHelpMap() { return m_helpMap.GetMap(); }
  176. virtual BOOL OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask);
  177. // Overrides
  178. // ClassWizard generate virtual function overrides
  179. //{{AFX_VIRTUAL(COptionsCfgPropPage)
  180. public:
  181. virtual BOOL OnSetActive();
  182. virtual BOOL OnApply();
  183. protected:
  184. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  185. //}}AFX_VIRTUAL
  186. // Implementation
  187. protected:
  188. // Generated message map functions
  189. //{{AFX_MSG(COptionsCfgPropPage)
  190. virtual BOOL OnInitDialog();
  191. /*afx_msg */ virtual void OnDestroy();
  192. afx_msg void OnItemchangedListOptions(NMHDR* pNMHDR, LRESULT* pResult);
  193. //}}AFX_MSG
  194. // IpAddress array controls
  195. afx_msg void OnButtonIpAddrDown();
  196. afx_msg void OnButtonIpAddrUp();
  197. afx_msg void OnButtonIpAddrAdd();
  198. afx_msg void OnButtonIpAddrDelete();
  199. afx_msg void OnSelchangeListIpAddrs();
  200. afx_msg void OnChangeIpAddressArray();
  201. afx_msg void OnChangeEditServerName();
  202. afx_msg void OnButtonResolve();
  203. // value array controls
  204. afx_msg void OnButtonValueDown();
  205. afx_msg void OnButtonValueUp();
  206. afx_msg void OnButtonValueAdd();
  207. afx_msg void OnButtonValueDelete();
  208. afx_msg void OnChangeEditValue();
  209. afx_msg void OnClickedRadioDecimal();
  210. afx_msg void OnClickedRadioHex();
  211. afx_msg void OnSelchangeListValues();
  212. // single value controls
  213. afx_msg void OnChangeEditDword();
  214. // string value controls
  215. afx_msg void OnChangeEditString();
  216. // single ip address controls
  217. afx_msg void OnChangeIpAddress();
  218. // single string controls
  219. // binary and encapsulated data
  220. afx_msg void OnChangeValueData();
  221. // route array controls
  222. afx_msg void OnButtonAddRoute();
  223. afx_msg void OnButtonDelRoute();
  224. // string array controls
  225. afx_msg void OnSelChangeStringArrayList();
  226. afx_msg void OnChangeStringArrayValue();
  227. afx_msg void OnButtonStringArrayAdd();
  228. afx_msg void OnButtonStringArrayRemove();
  229. afx_msg void OnButtonStringArrayUp();
  230. afx_msg void OnButtonStringArrayDown();
  231. afx_msg long OnSelectOption(UINT wParam, long lParam);
  232. DECLARE_MESSAGE_MAP()
  233. BOOL m_bInitialized;
  234. BYTE m_BinaryBuffer[MAXDATA_LENGTH];
  235. CHelpMap m_helpMap;
  236. };
  237. // the general page
  238. class COptionCfgGeneral : public COptionsCfgPropPage
  239. {
  240. DECLARE_DYNCREATE(COptionCfgGeneral)
  241. public:
  242. COptionCfgGeneral();
  243. COptionCfgGeneral(UINT nIDTemplate, UINT nIDCaption = 0);
  244. ~COptionCfgGeneral();
  245. // Dialog Data
  246. //{{AFX_DATA(COptionCfgGeneral)
  247. enum { IDD = IDP_OPTION_BASIC };
  248. //}}AFX_DATA
  249. // Overrides
  250. // ClassWizard generate virtual function overrides
  251. //{{AFX_VIRTUAL(COptionCfgGeneral)
  252. protected:
  253. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  254. //}}AFX_VIRTUAL
  255. // Implementation
  256. protected:
  257. // Generated message map functions
  258. //{{AFX_MSG(COptionCfgGeneral)
  259. virtual BOOL OnInitDialog();
  260. //}}AFX_MSG
  261. DECLARE_MESSAGE_MAP()
  262. };
  263. /////////////////////////////////////////////////////////////////////////////
  264. // CAddRoute dialog
  265. class CAddRoute : public CBaseDialog
  266. {
  267. // Construction
  268. public:
  269. CAddRoute(CWnd* pParent = NULL); // standard constructor
  270. // Dialog Data
  271. //{{AFX_DATA(CAddRoute)
  272. enum { IDD = IDD_ADD_ROUTE_DIALOG };
  273. //}}AFX_DATA
  274. // Ip address for destination, mask and router fields
  275. CWndIpAddress m_ipaDest, m_ipaMask, m_ipaRouter;
  276. BOOL m_bChange;
  277. DHCP_IP_ADDRESS Dest, Mask, Router;
  278. virtual DWORD * GetHelpMap() {
  279. return DhcpGetHelpMap( CAddRoute::IDD );
  280. }
  281. // Overrides
  282. // ClassWizard generated virtual function overrides
  283. //{{AFX_VIRTUAL(CAddRoute)
  284. protected:
  285. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  286. //}}AFX_VIRTUAL
  287. // Implementation
  288. protected:
  289. // Generated message map functions
  290. //{{AFX_MSG(CAddRoute)
  291. virtual BOOL OnInitDialog();
  292. virtual void OnOK();
  293. //}}AFX_MSG
  294. DECLARE_MESSAGE_MAP()
  295. };
  296. // the advanced page
  297. class COptionCfgAdvanced : public COptionsCfgPropPage
  298. {
  299. DECLARE_DYNCREATE(COptionCfgAdvanced)
  300. public:
  301. COptionCfgAdvanced();
  302. COptionCfgAdvanced(UINT nIDTemplate, UINT nIDCaption = 0);
  303. ~COptionCfgAdvanced();
  304. // Dialog Data
  305. //{{AFX_DATA(COptionCfgAdvanced)
  306. enum { IDD = IDP_OPTION_ADVANCED };
  307. CComboBox m_comboUserClasses;
  308. CComboBox m_comboVendorClasses;
  309. //}}AFX_DATA
  310. // Overrides
  311. // ClassWizard generate virtual function overrides
  312. //{{AFX_VIRTUAL(COptionCfgAdvanced)
  313. protected:
  314. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  315. //}}AFX_VIRTUAL
  316. // Implementation
  317. protected:
  318. // Generated message map functions
  319. //{{AFX_MSG(COptionCfgAdvanced)
  320. virtual BOOL OnInitDialog();
  321. afx_msg void OnSelendokComboUserClass();
  322. afx_msg void OnSelendokComboVendorClass();
  323. //}}AFX_MSG
  324. afx_msg long OnSelectClasses(UINT wParam, LONG lParam);
  325. BOOL m_bNoClasses;
  326. DECLARE_MESSAGE_MAP()
  327. };
  328. // the holder class for the pages
  329. class COptionsConfig : public CPropertyPageHolderBase
  330. {
  331. public:
  332. COptionsConfig(ITFSNode * pNode,
  333. ITFSNode * pServerNode,
  334. IComponentData * pComponentData,
  335. ITFSComponentData * pTFSCompData,
  336. COptionValueEnum * pOptionValueEnum,
  337. LPCTSTR pszSheetName,
  338. CDhcpOptionItem * pSelOption = NULL);
  339. virtual ~COptionsConfig();
  340. ITFSComponentData * GetTFSCompData()
  341. {
  342. if (m_spTFSCompData)
  343. m_spTFSCompData->AddRef();
  344. return m_spTFSCompData;
  345. }
  346. ITFSNode * GetServerNode()
  347. {
  348. if (m_spServerNode)
  349. m_spServerNode->AddRef();
  350. return m_spServerNode;
  351. }
  352. DWORD InitData();
  353. void FillOptions(LPCTSTR pVendorName, LPCTSTR pClassName, CMyListCtrl & ListCtrl);
  354. void UpdateActiveOptions();
  355. void SetTitle();
  356. LPWSTR GetServerAddress();
  357. void AddClassTracker(CVendorTracker * pVendorTracker, LPCTSTR pClassName);
  358. CVendorTracker * AddVendorTracker(LPCTSTR pVendorName);
  359. public:
  360. COptionCfgGeneral m_pageGeneral;
  361. COptionCfgAdvanced m_pageAdvanced;
  362. COptionValueEnum * m_pOptionValueEnum;
  363. CVendorTrackerList m_listVendorClasses;
  364. LARGE_INTEGER m_liServerVersion;
  365. // these descibe the option to focus on.
  366. CString m_strStartVendor;
  367. CString m_strStartClass;
  368. DHCP_OPTION_ID m_dhcpStartId;
  369. protected:
  370. SPITFSComponentData m_spTFSCompData;
  371. SPITFSNode m_spServerNode;
  372. BOOL m_bInitialized;
  373. };
  374. #endif _OPTCFG_H