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.

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