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.

286 lines
6.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: attredit.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _ATTREDIT_H
  11. #define _ATTREDIT_H
  12. #include "common.h"
  13. #include "attribute.h"
  14. #include "editor.h"
  15. // use the HIWORD for generic flags and leave the LOWORD for application specific data
  16. #define TN_FLAG_SHOW_MULTI (0x00010000) // shows combobox for multivalued attributes or edit box for single
  17. #define TN_FLAG_ENABLE_ADD (0x00020000) // shows add if set, shows set if not
  18. #define TN_FLAG_ENABLE_REMOVE (0x00040000) // shows remove if set, shows clear if not
  19. ////////////////////////////////////////////////////////////////////////
  20. class CAttrEditor;
  21. /////////////////////////////////////////////////////////////////////////
  22. // CADSIAttrList
  23. typedef CList<CADSIAttr*,CADSIAttr*> CAttrListBase;
  24. class CAttrList : public CAttrListBase
  25. {
  26. public:
  27. virtual ~CAttrList()
  28. {
  29. RemoveAllAttr();
  30. }
  31. void RemoveAllAttr()
  32. {
  33. while (!IsEmpty())
  34. delete RemoveTail();
  35. }
  36. POSITION FindProperty(LPCWSTR lpszAttr);
  37. BOOL HasProperty(LPCWSTR lpszAttr);
  38. void GetNextDirty(POSITION& pos, CADSIAttr** ppAttr);
  39. BOOL HasDirty();
  40. int GetDirtyCount()
  41. {
  42. int nCount = 0;
  43. POSITION pos = GetHeadPosition();
  44. while (pos != NULL)
  45. {
  46. if (GetNext(pos)->IsDirty())
  47. nCount++;
  48. }
  49. return nCount;
  50. }
  51. };
  52. ///////////////////////////////////////////////////////////////////////////
  53. // CDNSManageButtonTextHelper
  54. class CDNSManageButtonTextHelper
  55. {
  56. public:
  57. CDNSManageButtonTextHelper(int nStates);
  58. ~CDNSManageButtonTextHelper();
  59. BOOL Init(CWnd* pParentWnd, UINT nButtonID, UINT* nStrArray);
  60. void SetStateX(int nIndex);
  61. private:
  62. CWnd* m_pParentWnd;
  63. UINT m_nID;
  64. WCHAR* m_lpszText;
  65. int m_nStates;
  66. LPWSTR* m_lpszArr;
  67. };
  68. ///////////////////////////////////////////////////////////////////////////
  69. // CDNSButtonToggleTextHelper
  70. class CDNSButtonToggleTextHelper : public CDNSManageButtonTextHelper
  71. {
  72. public:
  73. CDNSButtonToggleTextHelper();
  74. void SetToggleState(BOOL bFirst) { SetStateX(bFirst ? 0 : 1); }
  75. };
  76. //////////////////////////////////////////////////////////////////////////////////////////
  77. // CADSIEditBox
  78. class CADSIEditBox : public CEdit
  79. {
  80. public:
  81. CADSIEditBox(CAttrEditor* pEditor)
  82. {
  83. ASSERT(pEditor != NULL);
  84. m_pEditor = pEditor;
  85. }
  86. afx_msg void OnChange();
  87. protected:
  88. CAttrEditor* m_pEditor;
  89. DECLARE_MESSAGE_MAP()
  90. };
  91. //////////////////////////////////////////////////////////////////////////////////////////
  92. // CADSIValueBox
  93. class CADSIValueBox : public CEdit
  94. {
  95. public:
  96. CADSIValueBox(CAttrEditor* pEditor)
  97. {
  98. ASSERT(pEditor != NULL);
  99. m_pEditor = pEditor;
  100. }
  101. protected:
  102. CAttrEditor* m_pEditor;
  103. DECLARE_MESSAGE_MAP()
  104. };
  105. //////////////////////////////////////////////////////////////////////////////////////////
  106. // CADSIValueList
  107. class CADSIValueList: public CListBox
  108. {
  109. public:
  110. CADSIValueList(CAttrEditor* pEditor)
  111. {
  112. ASSERT(pEditor != NULL);
  113. m_pEditor = pEditor;
  114. }
  115. afx_msg void OnSelChange();
  116. protected:
  117. CAttrEditor* m_pEditor;
  118. DECLARE_MESSAGE_MAP()
  119. };
  120. //////////////////////////////////////////////////////////////////////////////////////////
  121. // CADSIAddButton
  122. class CADSIAddButton: public CButton
  123. {
  124. public:
  125. CADSIAddButton(CAttrEditor* pEditor)
  126. {
  127. ASSERT(pEditor != NULL);
  128. m_pEditor = pEditor;
  129. }
  130. afx_msg void OnAdd();
  131. protected:
  132. CAttrEditor* m_pEditor;
  133. DECLARE_MESSAGE_MAP()
  134. };
  135. //////////////////////////////////////////////////////////////////////////////////////////
  136. // CADSIRemoveButton
  137. class CADSIRemoveButton: public CButton
  138. {
  139. public:
  140. CADSIRemoveButton(CAttrEditor* pEditor)
  141. {
  142. ASSERT(pEditor != NULL);
  143. m_pEditor = pEditor;
  144. }
  145. afx_msg void OnRemove();
  146. protected:
  147. CAttrEditor* m_pEditor;
  148. DECLARE_MESSAGE_MAP()
  149. };
  150. //////////////////////////////////////////////////////////////////////////////////////////
  151. // CAttrEditor
  152. class CAttrEditor
  153. {
  154. public:
  155. // Constructor
  156. //
  157. CAttrEditor();
  158. // Destructor
  159. //
  160. ~CAttrEditor()
  161. {
  162. }
  163. BOOL Initialize(CPropertyPageBase* pParentWnd, CTreeNode* pTreeNode, LPCWSTR lpszServer,
  164. UINT nIDEdit, UINT nIDSyntax,
  165. UINT nIDValueBox, UINT nIDValueList,
  166. UINT nIDAddButton, UINT nIDRemoveButton,
  167. BOOL bComplete);
  168. BOOL Initialize(CPropertyPageBase* pParentWnd, CConnectionData* pConnectData, LPCWSTR lpszServer,
  169. UINT nIDEdit, UINT nIDSyntax,
  170. UINT nIDValueBox, UINT nIDValueList,
  171. UINT nIDAddButton, UINT nIDRemoveButton,
  172. BOOL bComplete, CAttrList* pAttrList);
  173. // Message Map functions
  174. //
  175. BOOL OnApply();
  176. void OnEditChange();
  177. void OnValueSelChange();
  178. void OnAddValue();
  179. void OnRemoveValue();
  180. void SetAttribute(LPCWSTR lpszAttr, LPCWSTR lpszPath);
  181. // I return a CADSIAttr* because I check the cache to see if
  182. // that attribute has already been touched. If it has, the existing
  183. // attribute can be used to build the ui, if not a new one is created
  184. // and put into the cache. It is then returned to build the ui.
  185. //
  186. CADSIAttr* TouchAttr(LPCWSTR lpszAttr);
  187. CADSIAttr* TouchAttr(ADS_ATTR_INFO* pADsInfo, BOOL bMulti);
  188. protected:
  189. // Helper functions
  190. //
  191. void FillWithExisting();
  192. void DisplayAttribute();
  193. void DisplayFormatError();
  194. void DisplayRootDSE();
  195. BOOL IsMultiValued(ADS_ATTR_INFO* pAttrInfo);
  196. BOOL IsMultiValued(LPCWSTR lpszProp);
  197. BOOL IsRootDSEAttrMultiValued(LPCWSTR lpszAttr);
  198. void GetSyntax(LPCWSTR lpszProp, CString& sSyntax);
  199. void GetAttrFailed();
  200. void SetPropertyUI(DWORD dwFlags, BOOL bAnd, BOOL bReset = FALSE);
  201. // Dialog Items
  202. //
  203. CADSIEditBox m_AttrEditBox;
  204. CADSIEditBox m_SyntaxBox;
  205. CADSIValueBox m_ValueBox;
  206. CADSIValueList m_ValueList;
  207. CADSIAddButton m_AddButton;
  208. CADSIRemoveButton m_RemoveButton;
  209. CPropertyPageBase* m_pParentWnd;
  210. CTreeNode* m_pTreeNode;
  211. // Data members
  212. //
  213. CString m_sAttr;
  214. CString m_sPath;
  215. CString m_sServer;
  216. CString m_sNotSet;
  217. CAttrList* m_ptouchedAttr;
  218. CADSIAttr* m_pAttr;
  219. CConnectionData* m_pConnectData;
  220. BOOL m_bExisting;
  221. DWORD m_dwMultiFlags;
  222. CDNSButtonToggleTextHelper m_AddButtonHelper;
  223. CDNSButtonToggleTextHelper m_RemoveButtonHelper;
  224. };
  225. #endif _ATTREDIT_H