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.

421 lines
10 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) 1995-2001 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. #ifndef _SERVICE_H
  9. #define _SERVICE_H
  10. #include "hidwnd.h"
  11. #include "precdisp.h"
  12. // Forward declarations
  13. class CSnapin;
  14. class CResult;
  15. #define RESULT_GROUP_INFO_BASE 1
  16. #define RESULT_GROUP_INFO_SETTING 2
  17. #define RESULT_GROUP_INFO_STATUS 4
  18. // Internal structure used for cookies
  19. struct FOLDER_DATA {
  20. UINT ResID;
  21. UINT DescID;
  22. FOLDER_TYPES type;
  23. };
  24. typedef CList<CResult *, CResult *> CResultItemList;
  25. class CFolder {
  26. // friend class CSnapin;
  27. // friend class CComponentDataImpl;
  28. public:
  29. // UNINITIALIZED is an invalid memory address and is a good cookie initializer
  30. CFolder()
  31. {
  32. m_cookie = UNINITIALIZED;
  33. m_enumed = FALSE;
  34. m_pScopeItem = NULL;
  35. m_type = NONE;
  36. m_pszName = NULL;
  37. m_pszDesc = NULL;
  38. m_infName = NULL;
  39. m_dwMode = 0;
  40. m_ModeBits = 0;
  41. m_pData = NULL;
  42. m_iRefCount = 0;
  43. m_dwState = state_Unknown;
  44. m_ViewUpdate = FALSE;
  45. SetState(state_Unknown, state_Unknown);
  46. };
  47. virtual ~CFolder();
  48. // Interface
  49. public:
  50. BOOL IsEnumerated()
  51. {
  52. return m_enumed;
  53. };
  54. void Set(BOOL state)
  55. {
  56. m_enumed = state;
  57. };
  58. void SetCookie(MMC_COOKIE cookie)
  59. {
  60. m_cookie = cookie;
  61. }
  62. BOOL SetDesc(LPCTSTR szDesc);
  63. FOLDER_TYPES GetType()
  64. {
  65. ASSERT(m_type != NONE);
  66. return m_type;
  67. };
  68. LPOLESTR GetName()
  69. {
  70. return m_pszName;
  71. };
  72. LPOLESTR GetDesc()
  73. {
  74. return m_pszDesc;
  75. };
  76. LPOLESTR GetInfFile()
  77. {
  78. return m_infName;
  79. }
  80. DWORD GetDisplayName(CString &str, int iCol );
  81. void SetInfFile(LPOLESTR sz)
  82. {
  83. if (!m_infName)
  84. {
  85. m_infName = sz;
  86. }
  87. }
  88. BOOL operator == (const CFolder& rhs) const
  89. {
  90. return rhs.m_cookie == m_cookie;
  91. };
  92. BOOL operator == (long cookie) const
  93. {
  94. return cookie == m_cookie;
  95. };
  96. LPSCOPEDATAITEM GetScopeItem()
  97. {
  98. return m_pScopeItem;
  99. }
  100. BOOL SetMode(DWORD dwMode);
  101. DWORD GetMode()
  102. {
  103. return m_dwMode;
  104. }
  105. DWORD GetModeBits()
  106. {
  107. return m_ModeBits;
  108. }
  109. DWORD AddModeBits(DWORD dwMB)
  110. {
  111. return m_ModeBits |= dwMB;
  112. }
  113. PVOID GetData()
  114. {
  115. return m_pData;
  116. }
  117. void SetData(PVOID pData)
  118. {
  119. m_pData = pData;
  120. }
  121. // Implementation
  122. //private:
  123. HRESULT Create(LPCTSTR szName, LPCTSTR szDesc, LPCTSTR infName, int nImage,
  124. int nOpenImage, FOLDER_TYPES type, BOOL bHasChildren, DWORD dwMode,
  125. PVOID pData);
  126. DWORD GetState()
  127. {
  128. return m_dwState;
  129. };
  130. void SetState(
  131. DWORD dwState,
  132. DWORD dwMask = 0xFFFFFFFF)
  133. {
  134. m_dwState = (dwState | (m_dwState & dwMask));
  135. };
  136. public:
  137. //
  138. // Functions for objects.
  139. //
  140. BOOL SetDesc( DWORD dwStatus, DWORD dwNumChildren );
  141. BOOL GetObjectInfo( DWORD *pdwStatus, DWORD *pdwNumChildren );
  142. public:
  143. //
  144. // Result item member functions.
  145. //
  146. DWORD GetResultItemHandle( // Gets this folder result item handle
  147. HANDLE *handle);
  148. DWORD ReleaseResultItemHandle( // Releases memory associated with the handle.
  149. HANDLE &handle);
  150. DWORD GetResultItem( // Returns the result item with the given permission
  151. HANDLE handle,
  152. POSITION &pos,
  153. CResult **pResult);
  154. DWORD AddResultItem( // Adds a Result item to the list
  155. HANDLE handle,
  156. CResult *pItem);
  157. DWORD RemoveResultItem( // Removes a Result item
  158. HANDLE handle,
  159. CResult *pItem);
  160. int GetResultListCount() // Returns the number of result items in the list
  161. {
  162. return (int)m_resultItemList.GetCount();
  163. };
  164. POSITION GetResultItemPosition( // Returns the POSITION of the result item.
  165. HANDLE handle,
  166. CResult *pResult);
  167. void RemoveAllResultItems();
  168. public:
  169. BOOL GetViewUpdate() const;
  170. void SetViewUpdate(BOOL fUpdate);
  171. //
  172. // flags
  173. enum CFolderEnums {
  174. state_InvalidTemplate = 0x0001,
  175. state_Unknown = 0x0002,
  176. state_beingRemoved = 0x0004
  177. };
  178. // Attributes
  179. protected:
  180. int m_iRefCount;
  181. CResultItemList m_resultItemList;
  182. private:
  183. LPSCOPEDATAITEM m_pScopeItem;
  184. MMC_COOKIE m_cookie;
  185. BOOL m_enumed;
  186. FOLDER_TYPES m_type;
  187. LPOLESTR m_pszName;
  188. LPOLESTR m_pszDesc;
  189. LPOLESTR m_infName;
  190. DWORD m_dwMode;
  191. DWORD m_ModeBits;
  192. PVOID m_pData;
  193. BOOL m_ViewUpdate;
  194. DWORD m_dwState;
  195. };
  196. typedef struct _tag_SCECOLUMNINFO
  197. {
  198. LPCTSTR pszText;
  199. BOOL bDelete;
  200. }SCECOLUMNINFO, *PSCECOLUMNINFO;
  201. #define RRFCREATE_COPY 1
  202. #define RRFCREATE_DELETE 2
  203. #define RRFCREATE_NORMAL 3
  204. // Linked result items. Must be at least 4 for Analysis Groups at present
  205. #define MAX_ITEM_ID_INDEX 4
  206. #define NUM_GROUP_SIBLINGS 2
  207. class CResult
  208. {
  209. // friend class CSnapin;
  210. // friend class CComponentDataImpl;
  211. public:
  212. // UNINITIALIZED is an invalid memory address and is a good cookie initializer
  213. CResult()
  214. {
  215. m_szAttr = NULL;
  216. m_dwBase = 0;
  217. m_dwSetting = 0;
  218. m_type = ITEM_OTHER;
  219. m_status = SCE_STATUS_NOT_CONFIGURED;
  220. m_cookie = UNINITIALIZED;
  221. m_szUnits = NULL;
  222. m_nID = NULL;
  223. m_profBase = NULL;
  224. /*m_pDataObj = NULL;*/
  225. m_pNotify = NULL;
  226. m_pRegChoices = NULL;
  227. m_pRegFlags = NULL;
  228. m_pvecPrecedenceDisplays = NULL;
  229. m_iRefCount = 1;
  230. for (int i=0;i<NUM_GROUP_SIBLINGS;i++) {
  231. m_siblingCookies[i] = 0;
  232. }
  233. };
  234. void Empty()
  235. {
  236. PREGCHOICE p = NULL;
  237. while(m_pRegChoices)
  238. {
  239. p = m_pRegChoices->pNext;
  240. LocalFree(m_pRegChoices);
  241. m_pRegChoices = p;
  242. }
  243. PREGFLAGS f = NULL;
  244. while(m_pRegFlags)
  245. {
  246. f = m_pRegFlags->pNext;
  247. LocalFree(m_pRegFlags);
  248. m_pRegFlags = f;
  249. }
  250. if ( m_szAttr )
  251. {
  252. delete [] m_szAttr;
  253. m_szAttr = NULL;
  254. }
  255. if (ITEM_GROUP != m_type)
  256. {
  257. if( m_szUnits )
  258. {
  259. LocalFree(m_szUnits);
  260. m_szUnits = NULL;
  261. }
  262. }
  263. if (m_pvecPrecedenceDisplays)
  264. {
  265. for(vector<PPRECEDENCEDISPLAY>::iterator i = m_pvecPrecedenceDisplays->begin();
  266. i != m_pvecPrecedenceDisplays->end();
  267. ++i )
  268. {
  269. delete *i;
  270. }
  271. delete m_pvecPrecedenceDisplays;
  272. m_pvecPrecedenceDisplays = NULL;
  273. }
  274. }
  275. int AddRef()
  276. {
  277. return ++m_iRefCount;
  278. }
  279. int Release()
  280. {
  281. if (--m_iRefCount == 0)
  282. {
  283. delete this;
  284. return 0;
  285. }
  286. return m_iRefCount;
  287. };
  288. virtual ~CResult()
  289. {
  290. Empty();
  291. };
  292. // Interface
  293. public:
  294. void GetBaseNoUnit(LPTSTR& sz) { TranslateSettingToString(m_dwBase, NULL, m_type,&sz);};
  295. CSnapin* GetSnapin();
  296. DWORD_PTR GetProfileDefault();
  297. DWORD_PTR GetRegDefault();
  298. LPCTSTR GetAttrPretty();
  299. void Update(CSnapin *pSnapin, BOOL bEntirePane = FALSE);
  300. void SetRelativeCookies(MMC_COOKIE cookie1, MMC_COOKIE cookie2) { m_siblingCookies[0] = cookie1; m_siblingCookies[1] = cookie2;};
  301. MMC_COOKIE GetCookie() { return m_cookie;}
  302. RESULT_TYPES GetType() { return m_type;};
  303. LPTSTR GetAttr() { return m_szAttr;};
  304. LONG_PTR GetBase() { return m_dwBase;}
  305. LONG_PTR GetSetting() { return m_dwSetting;}
  306. void GetSetting(LPTSTR& sz) { TranslateSettingToString(m_dwSetting, m_szUnits, m_type,&sz);}
  307. void GetBase(LPTSTR& sz) { TranslateSettingToString(m_dwBase, m_szUnits, m_type,&sz);}
  308. BOOL operator == (LPTSTR attr) const { return lstrcmp(m_szAttr, attr) == 0;};
  309. void SetUnits(LPCTSTR sz);
  310. LPTSTR GetUnits() { return m_szUnits;}
  311. void SetBase(LONG_PTR base) { m_dwBase = base;}
  312. void SetSetting(LONG_PTR base) { m_dwSetting = base;}
  313. LONG_PTR GetID() { return m_nID;}
  314. void SetID(LONG_PTR nID) { m_nID = nID;}
  315. void SetStatus(int status) { m_status = status;}
  316. int GetStatus() { return m_status;}
  317. void SetRegChoices(PREGCHOICE RegChoices) { m_pRegChoices = RegChoices;}
  318. PREGCHOICE GetRegChoices() { return m_pRegChoices;}
  319. void SetRegFlags(PREGFLAGS RegFlags) { m_pRegFlags = RegFlags;}
  320. PREGFLAGS GetRegFlags() { return m_pRegFlags;}
  321. void SetBaseProfile(PEDITTEMPLATE prof) { m_profBase = prof;}
  322. PEDITTEMPLATE GetBaseProfile() { return m_profBase;}
  323. vector<PPRECEDENCEDISPLAY>* GetPrecedenceDisplays();
  324. vector<PPRECEDENCEDISPLAY>* GetPolicyPrecedenceDisplays();
  325. vector<PPRECEDENCEDISPLAY>* GetGroupPrecedenceDisplays();
  326. vector<PPRECEDENCEDISPLAY>* GetPrivilegePrecedenceDisplays();
  327. vector<PPRECEDENCEDISPLAY>* GetFilePrecedenceDisplays();
  328. vector<PPRECEDENCEDISPLAY>* GetRegistryPrecedenceDisplays();
  329. vector<PPRECEDENCEDISPLAY>* GetServicePrecedenceDisplays();
  330. vector<PPRECEDENCEDISPLAY>* GetRegValuePrecedenceDisplays();
  331. DWORD
  332. GetDisplayName(
  333. CFolder *pFolder,
  334. CString &str,
  335. int iCol
  336. );
  337. // Implementation
  338. HRESULT Create(LPCTSTR szAttr, LONG_PTR lBase, LONG_PTR lSetting,
  339. RESULT_TYPES type, int status, MMC_COOKIE cookie,
  340. LPCTSTR szUnits, LONG_PTR nID,PEDITTEMPLATE pBase,
  341. LPDATAOBJECT pDataObj,LPNOTIFY pNotify,CSnapin *pSnapin);
  342. LPCTSTR GetSourceGPOString();
  343. protected:
  344. void
  345. TranslateSettingToString( LONG_PTR setting, LPCTSTR unit, RESULT_TYPES type,
  346. LPTSTR *pTmpstr
  347. );
  348. DWORD
  349. GetStatusErrorString( CString *pStr );
  350. // Attributes
  351. private:
  352. //LPRESULTDATA m_pResultPane;
  353. DWORD m_dwArea;
  354. LPTSTR m_szAttr;
  355. LONG_PTR m_dwBase;
  356. LONG_PTR m_dwSetting;
  357. LPTSTR m_szUnits;
  358. RESULT_TYPES m_type;
  359. int m_status;
  360. MMC_COOKIE m_cookie;
  361. MMC_COOKIE m_siblingCookies[NUM_GROUP_SIBLINGS];
  362. LONG_PTR m_nID;
  363. PEDITTEMPLATE m_profBase;
  364. LPNOTIFY m_pNotify;
  365. PREGCHOICE m_pRegChoices;
  366. PREGFLAGS m_pRegFlags;
  367. CSnapin *m_pSnapin;
  368. vector<PPRECEDENCEDISPLAY>* m_pvecPrecedenceDisplays;
  369. int m_iRefCount;
  370. };
  371. #endif