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.

331 lines
8.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // CDSCookie
  3. //+-------------------------------------------------------------------------
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1999
  7. //
  8. // File: DSCache.h
  9. //
  10. // Contents: DS Cache functions
  11. //
  12. // History: 31-Jan-97 Jimharr Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef __DSCACHE_H__
  16. #define __DSCACHE_H__
  17. #include "dscolumn.h"
  18. #include "dsfilter.h" // FilterElementStruct
  19. //////////////////////////////////////////////////////////////////////////
  20. // helper functions
  21. void InitGroupTypeStringTable();
  22. LPCWSTR GetGroupTypeStringHelper(INT GroupType);
  23. //////////////////////////////////////////////////////////////////////////
  24. // fwd decl
  25. class CDSComponentData;
  26. class CMandatoryADsAttribute;
  27. class CMandatoryADsAttributeList;
  28. //////////////////////////////////////////////////////////////////////////
  29. // CDSClassCacheItemBase
  30. class CDSClassCacheItemBase
  31. {
  32. public:
  33. static HRESULT CreateItem(IN LPCWSTR lpszClass,
  34. IN IADs* pDSObject,
  35. IN CDSComponentData *pCD,
  36. OUT CDSClassCacheItemBase** ppItem);
  37. public:
  38. CDSClassCacheItemBase()
  39. {
  40. m_GUID = GUID_NULL;
  41. m_bIsContainer = FALSE;
  42. m_pMandPropsList = NULL;
  43. m_pColumnSet = NULL;
  44. m_pAdminPropertyPages = NULL;
  45. m_nAdminPPCount = 0;
  46. m_pAdminContextMenu = NULL;
  47. m_nAdminCMCount = 0;
  48. m_pAdminMultiSelectPropertyPages = NULL;
  49. m_nAdminMSPPCount = 0;
  50. }
  51. virtual ~CDSClassCacheItemBase();
  52. public:
  53. // accessor functions
  54. LPCWSTR GetClassName()
  55. {
  56. ASSERT(!m_szClass.IsEmpty());
  57. return m_szClass;
  58. }
  59. LPCWSTR GetFriendlyClassName()
  60. {
  61. ASSERT(!m_szFriendlyClassName.IsEmpty());
  62. return m_szFriendlyClassName;
  63. }
  64. LPCWSTR GetNamingAttribute()
  65. {
  66. ASSERT(!m_szNamingAttribute.IsEmpty());
  67. return m_szNamingAttribute;
  68. }
  69. // CDSColumnSet* GetColumnSet();
  70. GUID* GetGUID() { return &m_GUID; }
  71. BOOL IsContainer() { return m_bIsContainer; }
  72. BOOL SetContainerFlag(BOOL fIsContainer) { m_bIsContainer = fIsContainer; return m_bIsContainer; }
  73. CMandatoryADsAttributeList* GetMandatoryAttributeList(CDSComponentData* pCD);
  74. virtual int GetIconIndex(CDSCookie* pCookie, BOOL bOpen) = 0;
  75. //
  76. // Display Specifier cached accessors
  77. //
  78. virtual GUID* GetAdminPropertyPages(UINT* pnCount);
  79. virtual void SetAdminPropertyPages(UINT nCount, GUID* pGuids);
  80. virtual GUID* GetAdminContextMenu(UINT* pnCount);
  81. virtual void SetAdminContextMenu(UINT nCount, GUID* pGuids);
  82. virtual GUID* GetAdminMultiSelectPropertyPages(UINT* pnCount);
  83. virtual void SetAdminMultiSelectPropertyPages(UINT nCount, GUID* pGuids);
  84. protected:
  85. virtual HRESULT Init(LPCWSTR lpszClass, IADs* pDSObject, CDSComponentData *pCD);
  86. virtual void SetIconData(CDSComponentData *pCD) = 0;
  87. private:
  88. // data members
  89. CString m_szClass;
  90. CString m_szNamingAttribute; // class naming atrribute, eg. "cn" or "ou"
  91. CString m_szFriendlyClassName; // the friendly name for this class
  92. BOOL m_bIsContainer;
  93. GUID m_GUID;
  94. //
  95. // Display specifier GUID cache
  96. //
  97. GUID* m_pAdminPropertyPages;
  98. UINT m_nAdminPPCount;
  99. GUID* m_pAdminContextMenu;
  100. UINT m_nAdminCMCount;
  101. GUID* m_pAdminMultiSelectPropertyPages;
  102. UINT m_nAdminMSPPCount;
  103. CDSColumnSet* m_pColumnSet;
  104. CMandatoryADsAttributeList* m_pMandPropsList;
  105. };
  106. //////////////////////////////////////////////////////////////////////////
  107. // CDSClassIconIndexes
  108. class CDSClassIconIndexes
  109. {
  110. public:
  111. CDSClassIconIndexes()
  112. {
  113. m_iIconIndex = m_iIconIndexOpen = m_iIconIndexDisabled = -1;
  114. }
  115. int GetIconIndex(BOOL bDisabled, BOOL bOpen)
  116. {
  117. if (bDisabled)
  118. return m_iIconIndexDisabled;
  119. return bOpen ? m_iIconIndexOpen : m_iIconIndex;
  120. }
  121. void SetIconData(LPCWSTR lpszClass, BOOL bContainer, CDSComponentData *pCD, int nIconSet);
  122. private:
  123. int m_iIconIndex;
  124. int m_iIconIndexOpen;
  125. int m_iIconIndexDisabled;
  126. };
  127. //////////////////////////////////////////////////////////////////////////
  128. // CDSClassCacheItemGeneric
  129. class CDSClassCacheItemGeneric : public CDSClassCacheItemBase
  130. {
  131. public:
  132. virtual int GetIconIndex(CDSCookie* pCookie, BOOL bOpen);
  133. protected:
  134. virtual void SetIconData(CDSComponentData *pCD);
  135. CDSClassIconIndexes m_iconIndexesStandard;
  136. };
  137. //////////////////////////////////////////////////////////////////////////
  138. // CDSClassCacheItemUser
  139. class CDSClassCacheItemUser : public CDSClassCacheItemGeneric
  140. {
  141. };
  142. //////////////////////////////////////////////////////////////////////////
  143. // CDSClassCacheItemGroup
  144. class CDSClassCacheItemGroup : public CDSClassCacheItemGeneric
  145. {
  146. public:
  147. virtual int GetIconIndex(CDSCookie* pCookie, BOOL bOpen);
  148. protected:
  149. virtual void SetIconData(CDSComponentData *pCD);
  150. private:
  151. CDSClassIconIndexes m_iconIndexesAlternate;
  152. };
  153. //////////////////////////////////////////////////////////////////////////
  154. // CDSCache
  155. typedef CMap <CString, LPCTSTR, CDSClassCacheItemBase*, CDSClassCacheItemBase*> CDSCacheMap;
  156. class CDSCache
  157. {
  158. public:
  159. CDSCache() : m_pfilterelementDsAdminDrillDown(NULL), m_bDisplaySettingsCollected(FALSE)
  160. {
  161. ExceptionPropagatingInitializeCriticalSection(&m_cs);
  162. }
  163. ~CDSCache()
  164. {
  165. _Lock();
  166. _Cleanup();
  167. _CleanupColumns();
  168. _Unlock();
  169. ::DeleteCriticalSection(&m_cs);
  170. }
  171. private:
  172. CDSCache(const CDSCache&) {}
  173. CDSCache& operator=(const CDSCache&) {}
  174. public:
  175. BOOL ToggleExpandSpecialClasses(BOOL bContainer);
  176. CDSClassCacheItemBase* FindClassCacheItem(CDSComponentData* pCD,
  177. LPCWSTR lpszObjectClass,
  178. LPCWSTR lpszObjectLdapPath);
  179. BOOL Lookup(LPCTSTR lpsz, CDSClassCacheItemBase*& pItem)
  180. {
  181. _Lock();
  182. BOOL b = m_Map.Lookup(lpsz, pItem);
  183. _Unlock();
  184. return b;
  185. }
  186. //
  187. // Column Set List methods
  188. //
  189. CDSColumnSet* FindColumnSet(LPCWSTR lpszColumnID);
  190. void Initialize(SnapinType snapinType, MyBasePathsInfo* pBasePathsInfo, BOOL bFlushColumns)
  191. {
  192. _Lock();
  193. _Cleanup();
  194. if (bFlushColumns)
  195. {
  196. _CleanupColumns();
  197. m_ColumnList.Initialize(snapinType, pBasePathsInfo);
  198. }
  199. _Unlock();
  200. }
  201. HRESULT Save(IStream* pStm);
  202. HRESULT Load(IStream* pStm);
  203. HRESULT TabCollect_AddMultiSelectPropertyPages(LPPROPERTYSHEETCALLBACK pCall,
  204. LONG_PTR lNotifyHandle,
  205. LPDATAOBJECT pDataObject,
  206. MyBasePathsInfo* pBasePathsInfo);
  207. BOOL CanAddToGroup(MyBasePathsInfo* pBasePathsInfo, PCWSTR pszClass, BOOL bSecurity);
  208. FilterElementStruct* GetFilterElementStruct(CDSComponentData* pDSComponentData);
  209. private:
  210. void _Cleanup()
  211. {
  212. CString Key;
  213. CDSClassCacheItemBase* pCacheItem = NULL;
  214. POSITION pos = m_Map.GetStartPosition();
  215. while (!m_Map.IsEmpty())
  216. {
  217. m_Map.GetNextAssoc (pos, Key, pCacheItem);
  218. m_Map.RemoveKey (Key);
  219. delete pCacheItem;
  220. }
  221. m_szSecurityGroupExtraClasses.RemoveAll();
  222. m_szNonSecurityGroupExtraClasses.RemoveAll();
  223. m_bDisplaySettingsCollected = FALSE;
  224. //
  225. // Cleanup filter containers
  226. //
  227. _CleanupFilterContainers();
  228. }
  229. void _CleanupFilterContainers()
  230. {
  231. if (m_pfilterelementDsAdminDrillDown != NULL)
  232. {
  233. if (m_pfilterelementDsAdminDrillDown->ppTokens != NULL)
  234. {
  235. for (UINT idx = 0; idx < m_pfilterelementDsAdminDrillDown->cNumTokens; idx++)
  236. {
  237. if (m_pfilterelementDsAdminDrillDown->ppTokens[idx] != NULL)
  238. {
  239. delete[] m_pfilterelementDsAdminDrillDown->ppTokens[idx]->lpszString;
  240. m_pfilterelementDsAdminDrillDown->ppTokens[idx]->lpszString = NULL;
  241. }
  242. }
  243. delete[] m_pfilterelementDsAdminDrillDown->ppTokens;
  244. m_pfilterelementDsAdminDrillDown->ppTokens = NULL;
  245. }
  246. delete m_pfilterelementDsAdminDrillDown;
  247. m_pfilterelementDsAdminDrillDown = NULL;
  248. }
  249. }
  250. void _CleanupColumns()
  251. {
  252. m_ColumnList.RemoveAndDeleteAllColumnSets();
  253. }
  254. void _CollectDisplaySettings(MyBasePathsInfo* pBasePathsInfo);
  255. void _Lock() { ::EnterCriticalSection(&m_cs);}
  256. void _Unlock() { ::LeaveCriticalSection(&m_cs);}
  257. CRITICAL_SECTION m_cs;
  258. CDSCacheMap m_Map;
  259. CColumnSetList m_ColumnList;
  260. BOOL m_bDisplaySettingsCollected;
  261. CStringList m_szSecurityGroupExtraClasses;
  262. CStringList m_szNonSecurityGroupExtraClasses;
  263. FilterElementStruct* m_pfilterelementDsAdminDrillDown;
  264. };
  265. #endif //__DSCACHE_H__