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.

454 lines
13 KiB

  1. #ifndef __ATTRIBUTE_EDITOR_UI_H
  2. #define __ATTRIBUTE_EDITOR_UI_H
  3. #include "resource.h"
  4. #include "attr.h"
  5. #include "IAttrEdt.h"
  6. ////////////////////////////////////////////////////////////////////
  7. // CValueEditDialog - base class for creating syntax specific editors
  8. class CValueEditDialog : public CDialog
  9. {
  10. public:
  11. virtual ~CValueEditDialog() {}
  12. protected:
  13. //
  14. // Force subclassing of this class
  15. //
  16. CValueEditDialog(UINT nDlgID) : CDialog(nDlgID) {}
  17. private:
  18. CValueEditDialog() {}
  19. CValueEditDialog(const CValueEditDialog& copyref) {}
  20. CValueEditDialog& operator=(const CValueEditDialog& copyref) {}
  21. public:
  22. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  23. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  24. DECLARE_MESSAGE_MAP();
  25. protected:
  26. void GetClass(CString& szClassRef) { szClassRef = m_szClass; }
  27. void GetAttribute(CString& szAttributeRef) { szAttributeRef = m_szAttribute; }
  28. BOOL IsMultivalued() { return m_bMultivalued; }
  29. LPBINDINGFUNC GetBindingFunction() { return m_pfnBindingFunction; }
  30. LPARAM GetLParam() { return m_lParam; }
  31. PADSVALUE m_pOldADsValue;
  32. DWORD m_dwOldNumValues;
  33. CString m_szClass;
  34. CString m_szAttribute;
  35. BOOL m_bMultivalued;
  36. ADSTYPE m_adsType;
  37. LPBINDINGFUNC m_pfnBindingFunction;
  38. LPARAM m_lParam;
  39. };
  40. ////////////////////////////////////////////////////////////////////
  41. // LPEDITORDIALOGFUNC - editor creation function definition
  42. typedef CValueEditDialog* (*LPEDITORDIALOGFUNC)(PCWSTR pszClass,
  43. PCWSTR pszAttribute,
  44. ADSTYPE adsType,
  45. BOOL bMultivalued);
  46. ////////////////////////////////////////////////////////////////////
  47. // ATTR_EDITOR_MAP - struct used to map a specific attribute and
  48. // syntax to an editor
  49. typedef struct _attr_editor_map
  50. {
  51. PCWSTR pszClass;
  52. PCWSTR pszAttribute;
  53. ADSTYPE adsType;
  54. BOOL bMultivalued;
  55. LPEDITORDIALOGFUNC pfnCreateFunc;
  56. } ATTR_EDITOR_MAP, *PATTR_EDITOR_MAP;
  57. ////////////////////////////////////////////////////////////////////
  58. // CSingleStringEditor - string editor implementation for single valued
  59. // ADSTYPE_CASE_IGNORE_STRING,
  60. // ADSTYPE_CASE_EXACT_STRING,
  61. // ADSTYPE_PRINTABLE_STRING
  62. //
  63. class CSingleStringEditor : public CValueEditDialog
  64. {
  65. public:
  66. CSingleStringEditor() : CValueEditDialog(IDD_STRING_EDITOR_DIALOG)
  67. {}
  68. virtual BOOL OnInitDialog();
  69. virtual void OnOK();
  70. afx_msg void OnClear();
  71. DECLARE_MESSAGE_MAP();
  72. public:
  73. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  74. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  75. private:
  76. CString m_szOldValue;
  77. CString m_szNewValue;
  78. };
  79. CValueEditDialog* CreateSingleStringEditor(PCWSTR pszClass,
  80. PCWSTR pszAttribute,
  81. ADSTYPE adsType,
  82. BOOL bMultivalued);
  83. ////////////////////////////////////////////////////////////////////
  84. // CMultiStringEditor - string editor implementation for multivalued
  85. // ADSTYPE_CASE_IGNORE_STRING,
  86. // ADSTYPE_CASE_EXACT_STRING,
  87. // ADSTYPE_PRINTABLE_STRING
  88. //
  89. class CMultiStringEditor : public CValueEditDialog
  90. {
  91. public:
  92. CMultiStringEditor() : CValueEditDialog(IDD_STRING_EDITOR_MULTI_DIALOG)
  93. {}
  94. virtual BOOL OnInitDialog();
  95. virtual void OnOK();
  96. afx_msg void OnAddButton();
  97. afx_msg void OnRemoveButton();
  98. afx_msg void OnListSelChange();
  99. afx_msg void OnEditChange();
  100. DECLARE_MESSAGE_MAP();
  101. public:
  102. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  103. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  104. protected:
  105. void UpdateListboxHorizontalExtent();
  106. void ManageButtonStates();
  107. private:
  108. CStringList m_szOldValueList;
  109. CStringList m_szNewValueList;
  110. };
  111. CValueEditDialog* CreateMultiStringEditor(PCWSTR pszClass,
  112. PCWSTR pszAttribute,
  113. ADSTYPE adsType,
  114. BOOL bMultivalued);
  115. ////////////////////////////////////////////////////////////////////
  116. // CSingleIntEditor - string editor implementation for single valued
  117. // ADSTYPE_INTEGER
  118. //
  119. class CSingleIntEditor : public CValueEditDialog
  120. {
  121. public:
  122. CSingleIntEditor() : CValueEditDialog(IDD_INT_EDITOR_DIALOG)
  123. {
  124. m_bValueSet = FALSE;
  125. }
  126. virtual BOOL OnInitDialog();
  127. virtual void OnOK();
  128. afx_msg void OnClear();
  129. DECLARE_MESSAGE_MAP();
  130. public:
  131. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  132. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  133. private:
  134. DWORD m_dwOldValue;
  135. DWORD m_dwNewValue;
  136. BOOL m_bValueSet;
  137. };
  138. CValueEditDialog* CreateSingleIntEditor(PCWSTR pszClass,
  139. PCWSTR pszAttribute,
  140. ADSTYPE adsType,
  141. BOOL bMultivalued);
  142. ////////////////////////////////////////////////////////////////////
  143. // CSingleLargeIntEditor - string editor implementation for single valued
  144. // ADSTYPE_LARGE_INTEGER
  145. //
  146. class CSingleLargeIntEditor : public CValueEditDialog
  147. {
  148. public:
  149. CSingleLargeIntEditor() : CValueEditDialog(IDD_LARGEINT_EDITOR_DIALOG)
  150. {
  151. m_bValueSet = FALSE;
  152. }
  153. virtual BOOL OnInitDialog();
  154. virtual void OnOK();
  155. afx_msg void OnClear();
  156. DECLARE_MESSAGE_MAP();
  157. public:
  158. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  159. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  160. private:
  161. LARGE_INTEGER m_liOldValue;
  162. LARGE_INTEGER m_liNewValue;
  163. BOOL m_bValueSet;
  164. };
  165. CValueEditDialog* CreateSingleLargeIntEditor(PCWSTR pszClass,
  166. PCWSTR pszAttribute,
  167. ADSTYPE adsType,
  168. BOOL bMultivalued);
  169. ////////////////////////////////////////////////////////////////////
  170. // CSingleBooleanEditor - editor implementation for single valued
  171. // ADSTYPE_BOOLEAN
  172. //
  173. class CSingleBooleanEditor : public CValueEditDialog
  174. {
  175. public:
  176. CSingleBooleanEditor() : CValueEditDialog(IDD_BOOLEAN_EDITOR_DIALOG)
  177. {}
  178. virtual BOOL OnInitDialog();
  179. virtual void OnOK();
  180. DECLARE_MESSAGE_MAP();
  181. public:
  182. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  183. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  184. private:
  185. BOOL m_bOldValue;
  186. BOOL m_bNewValue;
  187. BOOL m_bValueSet;
  188. };
  189. CValueEditDialog* CreateSingleBooleanEditor(PCWSTR pszClass,
  190. PCWSTR pszAttribute,
  191. ADSTYPE adsType,
  192. BOOL bMultivalued);
  193. ////////////////////////////////////////////////////////////////////
  194. // CSingleTimeEditor - editor implementation for single valued
  195. // ADSTYPE_UTC_TIME
  196. //
  197. class CSingleTimeEditor : public CValueEditDialog
  198. {
  199. public:
  200. CSingleTimeEditor() : CValueEditDialog(IDD_TIME_EDITOR_DIALOG)
  201. {
  202. memset(&m_stOldValue, 0, sizeof(SYSTEMTIME));
  203. memset(&m_stNewValue, 0, sizeof(SYSTEMTIME));
  204. m_bValueSet = FALSE;
  205. }
  206. virtual BOOL OnInitDialog();
  207. virtual void OnOK();
  208. DECLARE_MESSAGE_MAP();
  209. public:
  210. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  211. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  212. private:
  213. SYSTEMTIME m_stOldValue;
  214. SYSTEMTIME m_stNewValue;
  215. BOOL m_bValueSet;
  216. };
  217. CValueEditDialog* CreateSingleTimeEditor(PCWSTR pszClass,
  218. PCWSTR pszAttribute,
  219. ADSTYPE adsType,
  220. BOOL bMultivalued);
  221. ////////////////////////////////////////////////////////////////////
  222. // COctetStringEditor - editor implementation for single valued
  223. // ADSTYPE_OCTET_STRING
  224. //
  225. #define MAX_OCTET_STRING_VALUE_LENGTH 200
  226. class COctetStringEditor : public CValueEditDialog
  227. {
  228. public:
  229. COctetStringEditor() : CValueEditDialog(IDD_OCTET_STRING_EDITOR_DIALOG)
  230. {
  231. m_dwOldLength = 0;
  232. m_pOldValue = NULL;
  233. m_dwNewLength = 0;
  234. m_pNewValue = NULL;
  235. m_bValueSet = FALSE;
  236. }
  237. ~COctetStringEditor()
  238. {
  239. if (m_pOldValue)
  240. {
  241. delete[] m_pOldValue;
  242. m_pOldValue = 0;
  243. }
  244. if (m_pNewValue)
  245. {
  246. delete[] m_pNewValue;
  247. m_pNewValue = 0;
  248. }
  249. }
  250. virtual BOOL OnInitDialog();
  251. virtual void OnOK();
  252. afx_msg void OnProcessEdit();
  253. afx_msg void OnEditButton();
  254. afx_msg void OnClearButton();
  255. DECLARE_MESSAGE_MAP();
  256. public:
  257. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  258. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  259. private:
  260. DWORD m_dwOldLength;
  261. BYTE* m_pOldValue;
  262. DWORD m_dwNewLength;
  263. BYTE* m_pNewValue;
  264. BOOL m_bValueSet;
  265. CByteArrayDisplay m_display;
  266. };
  267. CValueEditDialog* CreateSingleOctetStringEditor(PCWSTR pszClass,
  268. PCWSTR pszAttribute,
  269. ADSTYPE adsType,
  270. BOOL bMultivalued);
  271. ////////////////////////////////////////////////////////////////////
  272. // CMultiOctetStringEditor - octet string editor for multivalued
  273. // ADSTYPE_OCTET_STRING,
  274. //
  275. class CMultiOctetStringEditor : public CValueEditDialog
  276. {
  277. public:
  278. CMultiOctetStringEditor() : CValueEditDialog(IDD_OCTET_STRING_EDITOR_MULTI_DIALOG)
  279. {}
  280. virtual BOOL OnInitDialog();
  281. virtual void OnOK();
  282. afx_msg void OnAddButton();
  283. afx_msg void OnRemoveButton();
  284. afx_msg void OnEditButton();
  285. afx_msg void OnListSelChange();
  286. DECLARE_MESSAGE_MAP();
  287. public:
  288. virtual HRESULT Initialize(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  289. virtual HRESULT GetNewValue(PADSVALUE* ppADsValue, DWORD* pdwNumValues);
  290. protected:
  291. void UpdateListboxHorizontalExtent();
  292. void ManageButtonStates();
  293. private:
  294. CList<PADSVALUE, PADSVALUE> m_OldValueList;
  295. CList<PADSVALUE, PADSVALUE> m_NewValueList;
  296. };
  297. CValueEditDialog* CreateMultiOctetStringEditor(PCWSTR pszClass,
  298. PCWSTR pszAttribute,
  299. ADSTYPE adsType,
  300. BOOL bMultivalued);
  301. ////////////////////////////////////////////////////////////////////
  302. // CAttributeEditorPropertyPage - attribute editor property pages
  303. class CAttributeEditorPropertyPage : public CPropertyPage
  304. {
  305. public:
  306. CAttributeEditorPropertyPage(IADs* pIADs,
  307. IADsClass* pIADsClass,
  308. LPDS_ATTREDITOR_BINDINGINFO pBindingInfo,
  309. CADSIEditPropertyPageHolder* pHolder);
  310. ~CAttributeEditorPropertyPage();
  311. virtual BOOL OnInitDialog();
  312. virtual BOOL OnApply();
  313. afx_msg void OnMandatoryCheck();
  314. afx_msg void OnOptionalCheck();
  315. afx_msg void OnValueSetCheck();
  316. afx_msg void OnEditAttribute();
  317. afx_msg void OnSortList(NMHDR* pNotifyStruct, LRESULT* result);
  318. afx_msg void OnNotifyEditAttribute(NMHDR* pNotifyStruct, LRESULT* result);
  319. afx_msg void OnListItemChanged(NMHDR* pNotifyStruct, LRESULT* result);
  320. CADSIAttribute* GetAttributeFromList(int iSelectedItem);
  321. void GetAttributeInfo(CADSIAttribute* pAttr,
  322. LPDS_ATTRIBUTE_EDITORINFO* ppAttributeEditorInfo,
  323. BOOL* pbOwnValueMemory);
  324. void EditAttribute(CADSIAttribute* pSelectedAttr);
  325. void ShowListCtrl();
  326. HRESULT GetSchemaNamingContext();
  327. HRESULT RetrieveAttributes();
  328. void FillListControl();
  329. void SetEditButton();
  330. HRESULT CreateAttributeList(CStringList& sList, BOOL bMandatory);
  331. ADSTYPE RetrieveADsTypeFromSyntax(LPCWSTR lpszAttribute, BOOL* pbMultivalued, CString& szSyntax);
  332. CValueEditDialog* RetrieveEditor(LPDS_ATTRIBUTE_EDITORINFO pAttributeEditorInfo);
  333. UINT GetSortColumn() { return m_nSortColumn; }
  334. DECLARE_MESSAGE_MAP()
  335. private:
  336. CComPtr<IADs> m_spIADs;
  337. CComPtr<IADsClass> m_spIADsClass;
  338. BOOL m_bMandatory;
  339. BOOL m_bOptional;
  340. BOOL m_bSet;
  341. UINT m_nSortColumn;
  342. CAttrList2 m_AttrList;
  343. CStringList m_RootDSEValueList;
  344. CString m_szClass;
  345. CString m_szPrefix;
  346. CString m_szSchemaNamingContext;
  347. LPARAM m_BindLPARAM;
  348. LPBINDINGFUNC m_pfnBind;
  349. DWORD m_dwBindFlags;
  350. CADSIEditPropertyPageHolder* m_pHolder;
  351. };
  352. #endif //__ATTRIBUTE_EDITOR_UI_H