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.

453 lines
11 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 HandleActivationIpArray();
  169. void HandleActivationValueArray();
  170. void HandleActivationRouteArray(CDhcpOptionValue *optValue = NULL);
  171. BOOL HandleValueEdit();
  172. void MoveValue(BOOL bValues, BOOL bUp);
  173. // Context Help Support
  174. virtual DWORD * GetHelpMap() { return m_helpMap.GetMap(); }
  175. virtual BOOL OnPropertyChange(BOOL bScope, LONG_PTR *ChangeMask);
  176. // Overrides
  177. // ClassWizard generate virtual function overrides
  178. //{{AFX_VIRTUAL(COptionsCfgPropPage)
  179. public:
  180. virtual BOOL OnSetActive();
  181. virtual BOOL OnApply();
  182. protected:
  183. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  184. //}}AFX_VIRTUAL
  185. // Implementation
  186. protected:
  187. // Generated message map functions
  188. //{{AFX_MSG(COptionsCfgPropPage)
  189. virtual BOOL OnInitDialog();
  190. afx_msg void OnDestroy();
  191. afx_msg void OnItemchangedListOptions(NMHDR* pNMHDR, LRESULT* pResult);
  192. //}}AFX_MSG
  193. // IpAddress array controls
  194. afx_msg void OnButtonIpAddrDown();
  195. afx_msg void OnButtonIpAddrUp();
  196. afx_msg void OnButtonIpAddrAdd();
  197. afx_msg void OnButtonIpAddrDelete();
  198. afx_msg void OnSelchangeListIpAddrs();
  199. afx_msg void OnChangeIpAddressArray();
  200. afx_msg void OnChangeEditServerName();
  201. afx_msg void OnButtonResolve();
  202. // value array controls
  203. afx_msg void OnButtonValueDown();
  204. afx_msg void OnButtonValueUp();
  205. afx_msg void OnButtonValueAdd();
  206. afx_msg void OnButtonValueDelete();
  207. afx_msg void OnChangeEditValue();
  208. afx_msg void OnClickedRadioDecimal();
  209. afx_msg void OnClickedRadioHex();
  210. afx_msg void OnSelchangeListValues();
  211. // single value controls
  212. afx_msg void OnChangeEditDword();
  213. // string value controls
  214. afx_msg void OnChangeEditString();
  215. // single ip address controls
  216. afx_msg void OnChangeIpAddress();
  217. // single string controls
  218. // binary and encapsulated data
  219. afx_msg void OnChangeValueData();
  220. // route array controls
  221. afx_msg void OnButtonAddRoute();
  222. afx_msg void OnButtonDelRoute();
  223. afx_msg long OnSelectOption(UINT wParam, long lParam);
  224. DECLARE_MESSAGE_MAP()
  225. BOOL m_bInitialized;
  226. BYTE m_BinaryBuffer[MAXDATA_LENGTH];
  227. CHelpMap m_helpMap;
  228. };
  229. // the general page
  230. class COptionCfgGeneral : public COptionsCfgPropPage
  231. {
  232. DECLARE_DYNCREATE(COptionCfgGeneral)
  233. public:
  234. COptionCfgGeneral();
  235. COptionCfgGeneral(UINT nIDTemplate, UINT nIDCaption = 0);
  236. ~COptionCfgGeneral();
  237. // Dialog Data
  238. //{{AFX_DATA(COptionCfgGeneral)
  239. enum { IDD = IDP_OPTION_BASIC };
  240. //}}AFX_DATA
  241. // Overrides
  242. // ClassWizard generate virtual function overrides
  243. //{{AFX_VIRTUAL(COptionCfgGeneral)
  244. protected:
  245. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  246. //}}AFX_VIRTUAL
  247. // Implementation
  248. protected:
  249. // Generated message map functions
  250. //{{AFX_MSG(COptionCfgGeneral)
  251. virtual BOOL OnInitDialog();
  252. //}}AFX_MSG
  253. DECLARE_MESSAGE_MAP()
  254. };
  255. /////////////////////////////////////////////////////////////////////////////
  256. // CAddRoute dialog
  257. class CAddRoute : public CBaseDialog
  258. {
  259. // Construction
  260. public:
  261. CAddRoute(CWnd* pParent = NULL); // standard constructor
  262. // Dialog Data
  263. //{{AFX_DATA(CAddRoute)
  264. enum { IDD = IDD_ADD_ROUTE_DIALOG };
  265. //}}AFX_DATA
  266. // Ip address for destination, mask and router fields
  267. CWndIpAddress m_ipaDest, m_ipaMask, m_ipaRouter;
  268. BOOL m_bChange;
  269. DHCP_IP_ADDRESS Dest, Mask, Router;
  270. // Overrides
  271. // ClassWizard generated virtual function overrides
  272. //{{AFX_VIRTUAL(CAddRoute)
  273. protected:
  274. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  275. //}}AFX_VIRTUAL
  276. // Implementation
  277. protected:
  278. // Generated message map functions
  279. //{{AFX_MSG(CAddRoute)
  280. virtual BOOL OnInitDialog();
  281. virtual void OnOK();
  282. //}}AFX_MSG
  283. DECLARE_MESSAGE_MAP()
  284. };
  285. // the advanced page
  286. class COptionCfgAdvanced : public COptionsCfgPropPage
  287. {
  288. DECLARE_DYNCREATE(COptionCfgAdvanced)
  289. public:
  290. COptionCfgAdvanced();
  291. COptionCfgAdvanced(UINT nIDTemplate, UINT nIDCaption = 0);
  292. ~COptionCfgAdvanced();
  293. // Dialog Data
  294. //{{AFX_DATA(COptionCfgAdvanced)
  295. enum { IDD = IDP_OPTION_ADVANCED };
  296. CComboBox m_comboUserClasses;
  297. CComboBox m_comboVendorClasses;
  298. //}}AFX_DATA
  299. // Overrides
  300. // ClassWizard generate virtual function overrides
  301. //{{AFX_VIRTUAL(COptionCfgAdvanced)
  302. protected:
  303. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  304. //}}AFX_VIRTUAL
  305. // Implementation
  306. protected:
  307. // Generated message map functions
  308. //{{AFX_MSG(COptionCfgAdvanced)
  309. virtual BOOL OnInitDialog();
  310. afx_msg void OnSelendokComboUserClass();
  311. afx_msg void OnSelendokComboVendorClass();
  312. //}}AFX_MSG
  313. afx_msg long OnSelectClasses(UINT wParam, LONG lParam);
  314. BOOL m_bNoClasses;
  315. DECLARE_MESSAGE_MAP()
  316. };
  317. // the holder class for the pages
  318. class COptionsConfig : public CPropertyPageHolderBase
  319. {
  320. public:
  321. COptionsConfig(ITFSNode * pNode,
  322. ITFSNode * pServerNode,
  323. IComponentData * pComponentData,
  324. ITFSComponentData * pTFSCompData,
  325. COptionValueEnum * pOptionValueEnum,
  326. LPCTSTR pszSheetName,
  327. CDhcpOptionItem * pSelOption = NULL);
  328. virtual ~COptionsConfig();
  329. ITFSComponentData * GetTFSCompData()
  330. {
  331. if (m_spTFSCompData)
  332. m_spTFSCompData->AddRef();
  333. return m_spTFSCompData;
  334. }
  335. ITFSNode * GetServerNode()
  336. {
  337. if (m_spServerNode)
  338. m_spServerNode->AddRef();
  339. return m_spServerNode;
  340. }
  341. DWORD InitData();
  342. void FillOptions(LPCTSTR pVendorName, LPCTSTR pClassName, CMyListCtrl & ListCtrl);
  343. void UpdateActiveOptions();
  344. void SetTitle();
  345. LPWSTR GetServerAddress();
  346. void AddClassTracker(CVendorTracker * pVendorTracker, LPCTSTR pClassName);
  347. CVendorTracker * AddVendorTracker(LPCTSTR pVendorName);
  348. public:
  349. COptionCfgGeneral m_pageGeneral;
  350. COptionCfgAdvanced m_pageAdvanced;
  351. COptionValueEnum * m_pOptionValueEnum;
  352. CVendorTrackerList m_listVendorClasses;
  353. LARGE_INTEGER m_liServerVersion;
  354. // these descibe the option to focus on.
  355. CString m_strStartVendor;
  356. CString m_strStartClass;
  357. DHCP_OPTION_ID m_dhcpStartId;
  358. protected:
  359. SPITFSComponentData m_spTFSCompData;
  360. SPITFSNode m_spServerNode;
  361. BOOL m_bInitialized;
  362. };
  363. #endif _OPTCFG_H