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.

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