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.

236 lines
8.3 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Directory Service Property Pages
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1999
  7. //
  8. // File: objlist.h
  9. //
  10. // Contents: DS object list object header
  11. //
  12. // Classes:
  13. //
  14. // History: 20-Nov-97 EricB created
  15. //
  16. //-----------------------------------------------------------------------------
  17. #ifndef _OBJLIST_H_
  18. #define _OBJLIST_H_
  19. //#include <cdlink.hxx>
  20. //+----------------------------------------------------------------------------
  21. //
  22. // Class: CMemberListItem
  23. //
  24. // Purpose: membership list data item.
  25. //
  26. //-----------------------------------------------------------------------------
  27. class CMemberListItem : public CDLink
  28. {
  29. public:
  30. CMemberListItem(void) : m_pwzDN(NULL), m_ptzName(NULL), m_pSid(NULL),
  31. m_fSidSet(FALSE), m_fCanBePrimarySet(FALSE),
  32. m_fCanBePrimary(FALSE), m_fIsPrimary(FALSE),
  33. m_fIsAlreadyMember(FALSE), m_fIsExternal(FALSE),
  34. m_ulScopeType(0) {};
  35. ~CMemberListItem(void) {DO_DEL(m_pwzDN);
  36. DO_DEL(m_ptzName);
  37. DO_DEL(m_pSid);};
  38. // CDLink method overrides:
  39. CMemberListItem * Next(void) {return (CMemberListItem *)CDLink::Next();};
  40. CMemberListItem * Copy(void);
  41. BOOL IsSidSet(void) {return m_fSidSet;};
  42. BOOL IsCanBePrimarySet(void) {return m_fCanBePrimarySet;};
  43. BOOL CanBePrimary(void) {return m_fCanBePrimary;};
  44. void SetCanBePrimary(BOOL fCanBePrimary)
  45. {
  46. m_fCanBePrimary = fCanBePrimary;
  47. m_fCanBePrimarySet = TRUE;
  48. };
  49. BOOL SetSid(PSID pSid);
  50. PSID GetSid(void) {return m_pSid;};
  51. BOOL IsPrimary(void) {return m_fIsPrimary;};
  52. PWSTR m_pwzDN;
  53. PTSTR m_ptzName;
  54. PSID m_pSid;
  55. ULONG m_ulScopeType;
  56. BOOL m_fSidSet;
  57. BOOL m_fCanBePrimarySet;
  58. BOOL m_fCanBePrimary;
  59. BOOL m_fIsPrimary;
  60. BOOL m_fIsAlreadyMember;
  61. BOOL m_fIsExternal; // member is from an external domain and is
  62. // identified using the SID.
  63. };
  64. //+----------------------------------------------------------------------------
  65. //
  66. // Class: CMemberLinkList
  67. //
  68. // Purpose: Linked list of membership class objects.
  69. //
  70. //-----------------------------------------------------------------------------
  71. class CMemberLinkList
  72. {
  73. public:
  74. CMemberLinkList(void) : m_pListHead(NULL) {};
  75. ~CMemberLinkList(void);
  76. CMemberListItem * FindItemRemove(PWSTR pwzDN);
  77. CMemberListItem * FindItemRemove(PSID pSid);
  78. CMemberListItem * RemoveFirstItem(void);
  79. BOOL AddItem(CMemberListItem * pItem, BOOL fMember = TRUE);
  80. int GetItemCount(void);
  81. private:
  82. CMemberListItem * m_pListHead;
  83. };
  84. const int IDX_NAME_COL = 0;
  85. const int IDX_FOLDER_COL = 1;
  86. const int IDX_ERROR_COL = 1;
  87. const int OBJ_LIST_NAME_COL_WIDTH = 100;
  88. const int OBJ_LIST_PAGE_COL_WIDTH = 72;
  89. //+----------------------------------------------------------------------------
  90. //
  91. // Class: CDsObjList
  92. //
  93. // Purpose: Base class for DS object lists that employ a two column
  94. // list view to show object Name and Folder.
  95. //
  96. //-----------------------------------------------------------------------------
  97. class CDsObjList
  98. {
  99. public:
  100. CDsObjList(HWND hPage, int idList);
  101. ~CDsObjList(void);
  102. HRESULT Init(BOOL fShowIcons = FALSE);
  103. HRESULT InsertIntoList(PTSTR ptzDisplayName, PVOID pData, int iIcon = -1);
  104. HRESULT GetItem(int index, PTSTR * pptzName, PVOID * ppData);
  105. BOOL GetCurListItem(int * pIndex, PTSTR * pptzName, PVOID * ppData);
  106. BOOL GetCurListItems(int ** ppIndex, PTSTR ** ppptzName, PVOID ** pppData, int* pNumSelected);
  107. virtual BOOL RemoveListItem(int Index);
  108. int GetCount(void) {return ListView_GetItemCount(m_hList);};
  109. UINT GetSelectedCount(void) { return ListView_GetSelectedCount(m_hList);}
  110. virtual void ClearList(void) = 0;
  111. protected:
  112. HWND m_hPage;
  113. HWND m_hList;
  114. int m_idList;
  115. int m_nCurItem;
  116. BOOL m_fShowIcons;
  117. BOOL m_fLimitExceeded;
  118. };
  119. void GetNameParts(const CStr& cstrCanonicalNameEx, CStr& cstrFolder, CStr & cstrName);
  120. //+----------------------------------------------------------------------------
  121. //
  122. // Class: CDsMembershipList
  123. //
  124. // Purpose: Membership list class for the list-view control.
  125. //
  126. //-----------------------------------------------------------------------------
  127. class CDsMembershipList : public CDsObjList
  128. {
  129. public:
  130. CDsMembershipList(HWND hPage, int idList) : CDsObjList(hPage, idList) {};
  131. ~CDsMembershipList(void) {};
  132. HRESULT InsertIntoList(PTSTR ptzDisplayName, PVOID pData, int iIcon = -1)
  133. {return CDsObjList::InsertIntoList(ptzDisplayName, pData, iIcon);};
  134. HRESULT InsertIntoList(PWSTR pwzPath, int iIcon = -1)
  135. {return CDsMembershipList::InsertIntoList(pwzPath, iIcon, FALSE, FALSE,
  136. FALSE, FALSE, 0);};
  137. HRESULT InsertIntoNewList(PWSTR pwzPath, BOOL fPrimary = FALSE)
  138. {return CDsMembershipList::InsertIntoList(pwzPath, -1, TRUE,
  139. fPrimary, FALSE, TRUE, 0);};
  140. HRESULT InsertIntoList(PWSTR pwzPath, int iIcon, BOOL fAlreadyMember, BOOL fPrimary,
  141. BOOL fIgnoreDups, BOOL fDontChkDups, ULONG flScopeType);
  142. HRESULT InsertIntoList(PSID pSid, PWSTR pwzPath);
  143. HRESULT InsertIntoList(CMemberListItem * pItem);
  144. HRESULT InsertExternalIntoList(PWSTR pwzPath, ULONG ulScopeType)
  145. {return CDsMembershipList::InsertIntoList(pwzPath, -1, FALSE,
  146. FALSE, FALSE,
  147. FALSE, ulScopeType);};
  148. HRESULT MergeIntoList(PWSTR pwzPath)
  149. {return CDsMembershipList::InsertIntoList(pwzPath, -1, TRUE, FALSE, TRUE, FALSE, 0);};
  150. HRESULT GetItem(int index, CMemberListItem ** ppData)
  151. {return CDsObjList::GetItem(index, NULL, (PVOID *)ppData);};
  152. BOOL GetCurListItem(int * pIndex, PTSTR * pptzName, CMemberListItem ** ppData)
  153. {return CDsObjList::GetCurListItem(pIndex, pptzName, (PVOID *)ppData);};
  154. BOOL GetCurListItems(int ** ppIndex, PTSTR ** ppptzName, CMemberListItem *** pppData, int* pNumSelected)
  155. {return CDsObjList::GetCurListItems(ppIndex, ppptzName, (PVOID **)pppData, pNumSelected);};
  156. int GetIndex(LPCWSTR pwzDN, ULONG ulStart, ULONG ulEnd);
  157. BOOL RemoveListItem(int Index);
  158. void ClearList(void);
  159. HRESULT SetMemberIcons(CDsPropPageBase * pPage);
  160. };
  161. struct CLASS_CACHE_ENTRY
  162. {
  163. WCHAR wzClass[MAX_PATH];
  164. int iIcon;
  165. int iDisabledIcon;
  166. };
  167. #define ICON_CACHE_NUM_CLASSES 6
  168. //+--------------------------------------------------------------------------
  169. //
  170. // Class: CClassIconCache
  171. //
  172. // Purpose: Build an image list for well known DS classes and map the
  173. // image indices to the class names.
  174. //
  175. // Notes: CAUTION: the imagelist is destroyed in the dtor, therefore
  176. // it should only be used with listview controls that have
  177. // the LVS_SHAREIMAGELISTS style set.
  178. //
  179. //---------------------------------------------------------------------------
  180. class CClassIconCache
  181. {
  182. public:
  183. CClassIconCache(void);
  184. ~CClassIconCache(void);
  185. int GetClassIconIndex(PCWSTR pwzClass, BOOL fDisabled = FALSE);
  186. int AddClassIcon(PCWSTR pwzClass, BOOL fDisabled = FALSE);
  187. HIMAGELIST GetImageList(void);
  188. void ClearAll();
  189. private:
  190. HRESULT Initialize(void);
  191. BOOL m_fInitialized;
  192. CLASS_CACHE_ENTRY* m_prgcce;
  193. UINT m_nImageCount;
  194. HIMAGELIST m_hImageList;
  195. };
  196. extern CClassIconCache g_ClassIconCache;
  197. #endif // _OBJLIST_H_