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.

249 lines
6.5 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright (C) Microsoft Corporation, 1995 - 1999
  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 _FOLDERS_H
  9. #define _FOLDERS_H
  10. /////////////////////
  11. // File Versions
  12. // current version
  13. // removal of m_RowEnum
  14. #define VER_FOLDER_SAVE_STREAM_2 0x2
  15. // B3 version
  16. #define VER_FOLDER_SAVE_STREAM_1 0x1
  17. /////////////////////
  18. /////////////////////
  19. // File Versions
  20. // current version
  21. // removal of column sizes, sort order info, view type
  22. #define VER_CERTVIEWROWENUM_SAVE_STREAM_4 0x4
  23. // this version (written prior through Win2000 B3) includes column sizes
  24. #define VER_CERTVIEWROWENUM_SAVE_STREAM_3 0x3
  25. /////////////////////
  26. // Forward declarations
  27. class CSnapin;
  28. class CFolder;
  29. class CertSvrCA;
  30. class CertSvrMachine;
  31. struct RESULT_DATA
  32. {
  33. SCOPE_TYPES itemType;
  34. CFolder* pParentFolder;
  35. DWORD cStringArray;
  36. LPWSTR szStringArray[3]; // name, size, type
  37. };
  38. enum
  39. {
  40. RESULTDATA_ARRAYENTRY_NAME =0,
  41. RESULTDATA_ARRAYENTRY_SIZE,
  42. RESULTDATA_ARRAYENTRY_TYPE,
  43. };
  44. HRESULT IsColumnShown(MMC_COLUMN_SET_DATA* pCols, ULONG idxCol, BOOL* pfShown);
  45. HRESULT CountShownColumns(MMC_COLUMN_SET_DATA* pCols, ULONG* plCols);
  46. //////////////////////////////////////////////////////////////////////////
  47. // COLUMN TYPE cache
  48. //
  49. // This cache holds data that populated while setting column headings.
  50. // The data applies to the column view, not the database view.
  51. // Caching here allows an easy type-check during a compare() call, etc.
  52. typedef struct _COLUMN_TYPE_CACHE
  53. {
  54. // volatile members
  55. int iViewCol;
  56. } COLUMN_TYPE_CACHE;
  57. class CertViewRowEnum
  58. {
  59. protected:
  60. // View Interface
  61. ICertView* m_pICertView;
  62. BOOL m_fCertViewOpenAttempted;
  63. // Row Enum
  64. IEnumCERTVIEWROW* m_pRowEnum;
  65. LONG m_idxRowEnum;
  66. BOOL m_fRowEnumOpenAttempted;
  67. // Query Restrictions
  68. PQUERY_RESTRICTION m_pRestrictions;
  69. BOOL m_fRestrictionsActive;
  70. // Column property cache
  71. COLUMN_TYPE_CACHE* m_prgColPropCache;
  72. DWORD m_dwColumnCount;
  73. DWORD m_dwErr;
  74. public:
  75. CertViewRowEnum();
  76. virtual ~CertViewRowEnum();
  77. public:
  78. BOOL m_fKnowNumResultRows;
  79. DWORD m_dwResultRows;
  80. public:
  81. HRESULT GetLastError() { return m_dwErr; }
  82. // View Interface
  83. HRESULT GetView(CertSvrCA* pCA, ICertView** ppView);
  84. void ClearCachedCertView()
  85. { m_fCertViewOpenAttempted = FALSE; }
  86. // Row Enum
  87. HRESULT GetRowEnum(CertSvrCA* pCA, IEnumCERTVIEWROW** ppRowEnum);
  88. HRESULT GetRowMaxIndex(CertSvrCA* pCA, LONG* pidxMax);
  89. LONG GetRowEnumPos() { return m_idxRowEnum; }
  90. HRESULT SetRowEnumPos(LONG idxRow);
  91. HRESULT ResetCachedRowEnum(); // back to 0th row
  92. void InvalidateCachedRowEnum(); // refresh
  93. // Query Restrictions
  94. void SetQueryRestrictions(PQUERY_RESTRICTION pQR)
  95. { if (m_pRestrictions)
  96. FreeQueryRestrictionList(m_pRestrictions);
  97. m_pRestrictions = pQR;
  98. }
  99. PQUERY_RESTRICTION GetQueryRestrictions()
  100. { return m_pRestrictions; }
  101. BOOL FAreQueryRestrictionsActive()
  102. { return m_fRestrictionsActive; }
  103. void SetQueryRestrictionsActive(BOOL fRestrict)
  104. { m_fRestrictionsActive = fRestrict; }
  105. HRESULT ResetColumnCount(LONG lCols);
  106. LONG GetColumnCount()
  107. { return m_dwColumnCount; }
  108. // DB Column property cache
  109. void FreeColumnCacheInfo();
  110. HRESULT GetColumnCacheInfo(
  111. IN int iIndex,
  112. OUT OPTIONAL int* pidxViewCol);
  113. // sets column width by heading
  114. HRESULT SetColumnCacheInfo(
  115. IN int iIndex,
  116. IN int idxViewCol);
  117. public:
  118. // IPersistStream interface members
  119. HRESULT Load(IStream *pStm);
  120. HRESULT Save(IStream *pStm, BOOL fClearDirty);
  121. HRESULT GetSizeMax(int *pcbSize);
  122. };
  123. class CFolder
  124. {
  125. SCOPE_TYPES m_itemType; // Used for debug purposes. This should be the first
  126. // member. The class should not have any virtual fuctions.
  127. friend class CSnapin;
  128. friend class CComponentDataImpl;
  129. public:
  130. CFolder()
  131. {
  132. m_itemType = UNINITIALIZED_ITEM;
  133. m_cookie = UNINITIALIZED; // invalid memory address -- good cookie initializer
  134. m_enumed = FALSE;
  135. m_type = NONE;
  136. m_pszName = NULL;
  137. m_pCertCA = NULL;
  138. ZeroMemory(&m_ScopeItem, sizeof(SCOPEDATAITEM));
  139. }
  140. ~CFolder()
  141. {
  142. if (m_pszName)
  143. CoTaskMemFree(m_pszName);
  144. }
  145. // Interface
  146. public:
  147. BOOL IsEnumerated() { return m_enumed; }
  148. void Set(BOOL state) { m_enumed = state; }
  149. void SetCookie(MMC_COOKIE cookie) { m_cookie = cookie; }
  150. void SetScopeItemInformation(int nImage, int nOpenImage);
  151. FOLDER_TYPES GetType() { ASSERT(m_type != NONE); return m_type; }
  152. CertSvrCA* GetCA() { ASSERT(m_pCertCA != NULL); return m_pCertCA; }
  153. BOOL operator == (const CFolder& rhs) const { return rhs.m_cookie == m_cookie; }
  154. BOOL operator == (MMC_COOKIE cookie) const { return cookie == m_cookie; }
  155. LPCWSTR GetName() { return m_pszName; }
  156. void SetName(LPWSTR pszIn)
  157. {
  158. UINT len = wcslen(pszIn) + 1;
  159. LPWSTR psz = (LPWSTR)CoTaskMemAlloc(len * sizeof(WCHAR));
  160. if (psz != NULL)
  161. {
  162. wcscpy(psz, pszIn);
  163. CoTaskMemFree(m_pszName);
  164. m_pszName = psz;
  165. }
  166. }
  167. // IPersistStream interface members
  168. HRESULT Load(IStream *pStm);
  169. HRESULT Save(IStream *pStm, BOOL fClearDirty);
  170. HRESULT GetSizeMax(int *pcbSize);
  171. // Implementation
  172. private:
  173. void SetProperties(
  174. LPCWSTR szName,
  175. SCOPE_TYPES itemType,
  176. FOLDER_TYPES type,
  177. int iChildren = 0);
  178. // Attributes
  179. private:
  180. SCOPEDATAITEM m_ScopeItem;
  181. MMC_COOKIE m_cookie;
  182. BOOL m_enumed;
  183. FOLDER_TYPES m_type;
  184. LPOLESTR m_pszName;
  185. CertSvrCA* m_pCertCA;
  186. };
  187. BOOL IsAllowedStartStop(CFolder* pFolder, CertSvrMachine* pMachine);
  188. HRESULT GetCurrentColumnSchema(
  189. IN LPCWSTR szConfig,
  190. OUT CString** pprgcstrColumns,
  191. OUT OPTIONAL LONG** pprglTypes,
  192. OUT OPTIONAL BOOL** pprgfIndexed,
  193. OUT LONG* plEntries);
  194. #endif // _FOLDERS_H_