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.

614 lines
18 KiB

  1. #ifndef __ATTRIBUTE_EDITOR_UI_H
  2. #define __ATTRIBUTE_EDITOR_UI_H
  3. #include "resource.h"
  4. #include "attrres.h"
  5. #include "attr.h"
  6. #include "IAttrEdt.h"
  7. ////////////////////////////////////////////////////////////////////
  8. // CValueEditDialog - base class for creating syntax specific editors
  9. class CValueEditDialog : public CDialog
  10. {
  11. public:
  12. virtual ~CValueEditDialog() {}
  13. protected:
  14. //
  15. // Force subclassing of this class
  16. //
  17. CValueEditDialog(UINT nDlgID) : CDialog(nDlgID) {}
  18. private:
  19. CValueEditDialog() {}
  20. CValueEditDialog(const CValueEditDialog& copyref) {}
  21. CValueEditDialog& operator=(const CValueEditDialog& copyref) {}
  22. public:
  23. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  24. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  25. DECLARE_MESSAGE_MAP();
  26. protected:
  27. void GetClass(CString& szClassRef) { szClassRef = m_szClass; }
  28. void GetAttribute(CString& szAttributeRef) { szAttributeRef = m_szAttribute; }
  29. BOOL IsMultivalued() { return m_bMultivalued; }
  30. LPBINDINGFUNC GetBindingFunction() { return m_pfnBindingFunction; }
  31. LPARAM GetLParam() { return m_lParam; }
  32. PADSVALUE m_pOldADsValue;
  33. DWORD m_dwOldNumValues;
  34. CString m_szClass;
  35. CString m_szAttribute;
  36. BOOL m_bMultivalued;
  37. BOOL m_bReadOnly;
  38. ADSTYPE m_adsType;
  39. LPBINDINGFUNC m_pfnBindingFunction;
  40. LPARAM m_lParam;
  41. };
  42. ////////////////////////////////////////////////////////////////////
  43. // LPEDITORDIALOGFUNC - editor creation function definition
  44. typedef CValueEditDialog* (*LPEDITORDIALOGFUNC)(PCWSTR pszClass,
  45. PCWSTR pszAttribute,
  46. ADSTYPE adsType,
  47. BOOL bMultivalued);
  48. ////////////////////////////////////////////////////////////////////
  49. // ATTR_EDITOR_MAP - struct used to map a specific attribute and
  50. // syntax to an editor
  51. typedef struct _attr_editor_map
  52. {
  53. PCWSTR pszClass;
  54. PCWSTR pszAttribute;
  55. ADSTYPE adsType;
  56. BOOL bMultivalued;
  57. LPEDITORDIALOGFUNC pfnCreateFunc;
  58. } ATTR_EDITOR_MAP, *PATTR_EDITOR_MAP;
  59. ////////////////////////////////////////////////////////////////////
  60. // CSingleStringEditor - string editor implementation for single valued
  61. // ADSTYPE_CASE_IGNORE_STRING,
  62. // ADSTYPE_CASE_EXACT_STRING,
  63. // ADSTYPE_PRINTABLE_STRING
  64. //
  65. class CSingleStringEditor : public CValueEditDialog
  66. {
  67. public:
  68. CSingleStringEditor() : CValueEditDialog(IDD_STRING_EDITOR_DIALOG)
  69. {}
  70. virtual BOOL OnInitDialog();
  71. virtual void OnOK();
  72. afx_msg void OnClear();
  73. DECLARE_MESSAGE_MAP();
  74. public:
  75. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  76. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  77. private:
  78. CString m_szOldValue;
  79. CString m_szNewValue;
  80. };
  81. CValueEditDialog* CreateSingleStringEditor(PCWSTR pszClass,
  82. PCWSTR pszAttribute,
  83. ADSTYPE adsType,
  84. BOOL bMultivalued);
  85. ////////////////////////////////////////////////////////////////////
  86. // CMultiStringEditor - string editor implementation for multivalued
  87. // ADSTYPE_CASE_IGNORE_STRING,
  88. // ADSTYPE_CASE_EXACT_STRING,
  89. // ADSTYPE_PRINTABLE_STRING
  90. //
  91. class CMultiStringEditor : public CValueEditDialog
  92. {
  93. public:
  94. CMultiStringEditor() : CValueEditDialog(IDD_STRING_EDITOR_MULTI_DIALOG)
  95. {}
  96. virtual BOOL OnInitDialog();
  97. virtual void OnOK();
  98. afx_msg void OnAddButton();
  99. afx_msg void OnRemoveButton();
  100. afx_msg void OnListSelChange();
  101. afx_msg void OnEditChange();
  102. DECLARE_MESSAGE_MAP();
  103. public:
  104. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  105. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  106. protected:
  107. void UpdateListboxHorizontalExtent();
  108. void ManageButtonStates();
  109. private:
  110. CStringList m_szOldValueList;
  111. CStringList m_szNewValueList;
  112. };
  113. CValueEditDialog* CreateMultiStringEditor(PCWSTR pszClass,
  114. PCWSTR pszAttribute,
  115. ADSTYPE adsType,
  116. BOOL bMultivalued);
  117. ////////////////////////////////////////////////////////////////////
  118. // CSingleIntEditor - string editor implementation for single valued
  119. // ADSTYPE_INTEGER
  120. //
  121. class CSingleIntEditor : public CValueEditDialog
  122. {
  123. public:
  124. CSingleIntEditor() : CValueEditDialog(IDD_INT_EDITOR_DIALOG)
  125. {
  126. m_bValueSet = FALSE;
  127. }
  128. virtual BOOL OnInitDialog();
  129. virtual void OnOK();
  130. afx_msg void OnClear();
  131. DECLARE_MESSAGE_MAP();
  132. public:
  133. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  134. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  135. private:
  136. DWORD m_dwOldValue;
  137. DWORD m_dwNewValue;
  138. BOOL m_bValueSet;
  139. };
  140. CValueEditDialog* CreateSingleIntEditor(PCWSTR pszClass,
  141. PCWSTR pszAttribute,
  142. ADSTYPE adsType,
  143. BOOL bMultivalued);
  144. ////////////////////////////////////////////////////////////////////
  145. // CMultiIntEditor - string editor implementation for multivalued
  146. // ADSTYPE_INTEGER,
  147. //
  148. class CMultiIntEditor : public CValueEditDialog
  149. {
  150. public:
  151. CMultiIntEditor() : CValueEditDialog(IDD_STRING_EDITOR_MULTI_DIALOG)
  152. {}
  153. virtual BOOL OnInitDialog();
  154. virtual void OnOK();
  155. afx_msg void OnAddButton();
  156. afx_msg void OnRemoveButton();
  157. afx_msg void OnListSelChange();
  158. afx_msg void OnEditChange();
  159. DECLARE_MESSAGE_MAP();
  160. public:
  161. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  162. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  163. protected:
  164. void UpdateListboxHorizontalExtent();
  165. void ManageButtonStates();
  166. private:
  167. CList<int, int> m_oldValueList;
  168. CList<int, int> m_newValueList;
  169. };
  170. CValueEditDialog* CreateMultiIntEditor(PCWSTR pszClass,
  171. PCWSTR pszAttribute,
  172. ADSTYPE adsType,
  173. BOOL bMultivalued);
  174. ////////////////////////////////////////////////////////////////////
  175. // CSingleLargeIntEditor - string editor implementation for single valued
  176. // ADSTYPE_LARGE_INTEGER
  177. //
  178. class CSingleLargeIntEditor : public CValueEditDialog
  179. {
  180. public:
  181. CSingleLargeIntEditor() : CValueEditDialog(IDD_LARGEINT_EDITOR_DIALOG)
  182. {
  183. m_bValueSet = FALSE;
  184. }
  185. virtual BOOL OnInitDialog();
  186. virtual void OnOK();
  187. afx_msg void OnClear();
  188. DECLARE_MESSAGE_MAP();
  189. public:
  190. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  191. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  192. private:
  193. LARGE_INTEGER m_liOldValue;
  194. LARGE_INTEGER m_liNewValue;
  195. BOOL m_bValueSet;
  196. };
  197. CValueEditDialog* CreateSingleLargeIntEditor(PCWSTR pszClass,
  198. PCWSTR pszAttribute,
  199. ADSTYPE adsType,
  200. BOOL bMultivalued);
  201. ////////////////////////////////////////////////////////////////////
  202. // CSingleBooleanEditor - editor implementation for single valued
  203. // ADSTYPE_BOOLEAN
  204. //
  205. class CSingleBooleanEditor : public CValueEditDialog
  206. {
  207. public:
  208. CSingleBooleanEditor() : CValueEditDialog(IDD_BOOLEAN_EDITOR_DIALOG)
  209. {}
  210. virtual BOOL OnInitDialog();
  211. virtual void OnOK();
  212. DECLARE_MESSAGE_MAP();
  213. public:
  214. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  215. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  216. private:
  217. BOOL m_bOldValue;
  218. BOOL m_bNewValue;
  219. BOOL m_bValueSet;
  220. };
  221. CValueEditDialog* CreateSingleBooleanEditor(PCWSTR pszClass,
  222. PCWSTR pszAttribute,
  223. ADSTYPE adsType,
  224. BOOL bMultivalued);
  225. ////////////////////////////////////////////////////////////////////
  226. // CMultiBooleanEditor - boolean editor implementation for multivalued
  227. // ADSTYPE_BOOLEAN
  228. //
  229. class CMultiBooleanEditor : public CValueEditDialog
  230. {
  231. public:
  232. CMultiBooleanEditor() : CValueEditDialog(IDD_BOOLEAN_EDITOR_MULTI_DIALOG)
  233. {}
  234. virtual BOOL OnInitDialog();
  235. virtual void OnOK();
  236. afx_msg void OnAddButton();
  237. afx_msg void OnRemoveButton();
  238. afx_msg void OnListSelChange();
  239. afx_msg void OnRadioChange();
  240. DECLARE_MESSAGE_MAP();
  241. public:
  242. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  243. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  244. protected:
  245. void UpdateListboxHorizontalExtent();
  246. void ManageButtonStates();
  247. private:
  248. CList<BOOL, BOOL> m_bOldValueList;
  249. CList<BOOL, BOOL> m_bNewValueList;
  250. };
  251. CValueEditDialog* CreateMultiBooleanEditor(PCWSTR pszClass,
  252. PCWSTR pszAttribute,
  253. ADSTYPE adsType,
  254. BOOL bMultivalued);
  255. ////////////////////////////////////////////////////////////////////
  256. // CSingleTimeEditor - editor implementation for single valued
  257. // ADSTYPE_UTC_TIME
  258. //
  259. class CSingleTimeEditor : public CValueEditDialog
  260. {
  261. public:
  262. CSingleTimeEditor() : CValueEditDialog(IDD_TIME_EDITOR_DIALOG)
  263. {
  264. memset(&m_stOldValue, 0, sizeof(SYSTEMTIME));
  265. memset(&m_stNewValue, 0, sizeof(SYSTEMTIME));
  266. m_bValueSet = FALSE;
  267. }
  268. virtual BOOL OnInitDialog();
  269. virtual void OnOK();
  270. DECLARE_MESSAGE_MAP();
  271. public:
  272. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  273. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  274. private:
  275. SYSTEMTIME m_stOldValue;
  276. SYSTEMTIME m_stNewValue;
  277. BOOL m_bValueSet;
  278. };
  279. CValueEditDialog* CreateSingleTimeEditor(PCWSTR pszClass,
  280. PCWSTR pszAttribute,
  281. ADSTYPE adsType,
  282. BOOL bMultivalued);
  283. ////////////////////////////////////////////////////////////////////
  284. // CMultiTimeEditor - time editor implementation for multivalued
  285. // ADSTYPE_UTC_TIME
  286. //
  287. class CMultiTimeEditor : public CValueEditDialog
  288. {
  289. public:
  290. CMultiTimeEditor() : CValueEditDialog(IDD_TIME_EDITOR_MULTI_DIALOG)
  291. {}
  292. virtual BOOL OnInitDialog();
  293. virtual void OnOK();
  294. afx_msg void OnAddButton();
  295. afx_msg void OnRemoveButton();
  296. afx_msg void OnListSelChange();
  297. DECLARE_MESSAGE_MAP();
  298. public:
  299. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  300. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  301. protected:
  302. void UpdateListboxHorizontalExtent();
  303. void ManageButtonStates();
  304. private:
  305. CList<SYSTEMTIME*, SYSTEMTIME*> m_stOldValueList;
  306. CList<SYSTEMTIME*, SYSTEMTIME*> m_stNewValueList;
  307. };
  308. CValueEditDialog* CreateMultiTimeEditor(PCWSTR pszClass,
  309. PCWSTR pszAttribute,
  310. ADSTYPE adsType,
  311. BOOL bMultivalued);
  312. ////////////////////////////////////////////////////////////////////
  313. // COctetStringEditor - editor implementation for single valued
  314. // ADSTYPE_OCTET_STRING
  315. //
  316. #define MAX_OCTET_STRING_VALUE_LENGTH 200
  317. class COctetStringEditor : public CValueEditDialog
  318. {
  319. public:
  320. COctetStringEditor() : CValueEditDialog(IDD_OCTET_STRING_EDITOR_DIALOG)
  321. {
  322. m_dwOldLength = 0;
  323. m_pOldValue = NULL;
  324. m_dwNewLength = 0;
  325. m_pNewValue = NULL;
  326. m_bValueSet = FALSE;
  327. }
  328. ~COctetStringEditor()
  329. {
  330. if (m_pOldValue)
  331. {
  332. delete[] m_pOldValue;
  333. m_pOldValue = 0;
  334. }
  335. if (m_pNewValue)
  336. {
  337. delete[] m_pNewValue;
  338. m_pNewValue = 0;
  339. }
  340. }
  341. virtual BOOL OnInitDialog();
  342. virtual void OnOK();
  343. afx_msg void OnProcessEdit();
  344. afx_msg void OnEditButton();
  345. afx_msg void OnClearButton();
  346. DECLARE_MESSAGE_MAP();
  347. public:
  348. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  349. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  350. private:
  351. DWORD m_dwOldLength;
  352. BYTE* m_pOldValue;
  353. DWORD m_dwNewLength;
  354. BYTE* m_pNewValue;
  355. BOOL m_bValueSet;
  356. CByteArrayDisplay m_display;
  357. };
  358. CValueEditDialog* CreateSingleOctetStringEditor(PCWSTR pszClass,
  359. PCWSTR pszAttribute,
  360. ADSTYPE adsType,
  361. BOOL bMultivalued);
  362. ////////////////////////////////////////////////////////////////////
  363. // CMultiOctetStringEditor - octet string editor for multivalued
  364. // ADSTYPE_OCTET_STRING,
  365. //
  366. class CMultiOctetStringEditor : public CValueEditDialog
  367. {
  368. public:
  369. CMultiOctetStringEditor() : CValueEditDialog(IDD_OCTET_STRING_EDITOR_MULTI_DIALOG)
  370. {}
  371. virtual BOOL OnInitDialog();
  372. virtual void OnOK();
  373. afx_msg void OnAddButton();
  374. afx_msg void OnRemoveButton();
  375. afx_msg void OnEditButton();
  376. afx_msg void OnListSelChange();
  377. DECLARE_MESSAGE_MAP();
  378. public:
  379. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  380. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  381. protected:
  382. void UpdateListboxHorizontalExtent();
  383. void ManageButtonStates();
  384. private:
  385. CList<PADSVALUE, PADSVALUE> m_OldValueList;
  386. CList<PADSVALUE, PADSVALUE> m_NewValueList;
  387. };
  388. CValueEditDialog* CreateMultiOctetStringEditor(PCWSTR pszClass,
  389. PCWSTR pszAttribute,
  390. ADSTYPE adsType,
  391. BOOL bMultivalued);
  392. ////////////////////////////////////////////////////////////////////
  393. // CDNWithStringEditor - DN with String editor for editing
  394. // ADSTYPE_DN_WITH_STRING
  395. //
  396. class CDNWithStringEditor : public CValueEditDialog
  397. {
  398. public:
  399. CDNWithStringEditor() : CValueEditDialog(IDD_DN_WITH_STRING_EDITOR_DIALOG)
  400. {}
  401. virtual BOOL OnInitDialog();
  402. virtual void OnOK();
  403. afx_msg void OnClear();
  404. DECLARE_MESSAGE_MAP();
  405. public:
  406. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  407. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  408. private:
  409. CString m_OldDNValue;
  410. CString m_OldStringValue;
  411. CString m_NewDNValue;
  412. CString m_NewStringValue;
  413. };
  414. CValueEditDialog* CreateDNWithStringEditor(PCWSTR pszClass,
  415. PCWSTR pszAttribute,
  416. ADSTYPE adsType,
  417. BOOL bMultivalued);
  418. ////////////////////////////////////////////////////////////////////
  419. // CAttributeEditorPropertyPage - attribute editor property pages
  420. class CAttributeEditorPropertyPage : public CPropertyPage
  421. {
  422. public:
  423. CAttributeEditorPropertyPage(IADs* pIADs,
  424. IADsClass* pIADsClass,
  425. LPDS_ATTREDITOR_BINDINGINFO pBindingInfo,
  426. CADSIEditPropertyPageHolder* pHolder);
  427. ~CAttributeEditorPropertyPage();
  428. virtual BOOL OnInitDialog();
  429. virtual BOOL OnApply();
  430. virtual void OnDestroy();
  431. virtual int OnCreate(LPCREATESTRUCT lpCreateStruct);
  432. afx_msg void OnMandatoryCheck();
  433. afx_msg void OnOptionalCheck();
  434. afx_msg void OnValueSetCheck();
  435. afx_msg void OnEditAttribute();
  436. afx_msg void OnSortList(NMHDR* pNotifyStruct, LRESULT* result);
  437. afx_msg void OnNotifyEditAttribute(NMHDR* pNotifyStruct, LRESULT* result);
  438. afx_msg void OnListItemChanged(NMHDR* pNotifyStruct, LRESULT* result);
  439. CADSIAttribute* GetAttributeFromList(int iSelectedItem);
  440. HRESULT GetAttributeInfo(CADSIAttribute& pAttr,
  441. LPDS_ATTRIBUTE_EDITORINFO* ppAttributeEditorInfo,
  442. BOOL* pbOwnValueMemory);
  443. void EditAttribute(CADSIAttribute* pSelectedAttr);
  444. void ShowListCtrl();
  445. HRESULT GetSchemaNamingContext();
  446. HRESULT RetrieveAttributes();
  447. bool IsRangeOfValues(PCWSTR pszAttrName,
  448. CString& szAttrBase,
  449. DWORD& rangeStart,
  450. DWORD& rangeEnd);
  451. void FillListControl();
  452. void SetEditButton();
  453. HRESULT CreateAttributeList(CStringList& sList, BOOL bMandatory);
  454. ADSTYPE RetrieveADsTypeFromSyntax(LPCWSTR lpszAttribute, BOOL* pbMultivalued, CString& szSyntax);
  455. CValueEditDialog* RetrieveEditor(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  456. UINT GetSortColumn() { return m_nSortColumn; }
  457. DECLARE_MESSAGE_MAP()
  458. private:
  459. CComPtr<IADs> m_spIADs;
  460. CComPtr<IADsClass> m_spIADsClass;
  461. BOOL m_bMandatory;
  462. BOOL m_bOptional;
  463. BOOL m_bSet;
  464. UINT m_nSortColumn;
  465. CAttrList2 m_AttrList;
  466. CStringList m_RootDSEValueList;
  467. CString m_szClass;
  468. CString m_szPrefix;
  469. CString m_szSchemaNamingContext;
  470. LPARAM m_BindLPARAM;
  471. LPBINDINGFUNC m_pfnBind;
  472. DWORD m_dwBindFlags;
  473. CADSIEditPropertyPageHolder* m_pHolder;
  474. };
  475. #endif //__ATTRIBUTE_EDITOR_UI_H