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.

250 lines
6.9 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[2];
  69. BOOL m_fRestrictionsActive[2];
  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. BOOL m_fCertView;
  81. public:
  82. HRESULT GetLastError() { return m_dwErr; }
  83. // View Interface
  84. HRESULT GetView(CertSvrCA* pCA, ICertView** ppView);
  85. void ClearCachedCertView()
  86. { m_fCertViewOpenAttempted = FALSE; }
  87. // Row Enum
  88. HRESULT GetRowEnum(CertSvrCA* pCA, IEnumCERTVIEWROW** ppRowEnum);
  89. HRESULT GetRowMaxIndex(CertSvrCA* pCA, LONG* pidxMax);
  90. LONG GetRowEnumPos() { return m_idxRowEnum; }
  91. HRESULT SetRowEnumPos(LONG idxRow);
  92. HRESULT ResetCachedRowEnum(); // back to 0th row
  93. void InvalidateCachedRowEnum(); // refresh
  94. // Query Restrictions
  95. void SetQueryRestrictions(PQUERY_RESTRICTION pQR, int i)
  96. { if (m_pRestrictions[i])
  97. FreeQueryRestrictionList(m_pRestrictions[i]);
  98. m_pRestrictions[i] = pQR;
  99. }
  100. PQUERY_RESTRICTION GetQueryRestrictions(int i)
  101. { return m_pRestrictions[i]; }
  102. BOOL FAreQueryRestrictionsActive(int i)
  103. { return m_fRestrictionsActive[i]; }
  104. void SetQueryRestrictionsActive(BOOL fRestrict, int i)
  105. { m_fRestrictionsActive[i] = fRestrict; }
  106. HRESULT ResetColumnCount(LONG lCols);
  107. LONG GetColumnCount()
  108. { return m_dwColumnCount; }
  109. // DB Column property cache
  110. void FreeColumnCacheInfo();
  111. HRESULT GetColumnCacheInfo(
  112. IN int iIndex,
  113. OUT OPTIONAL int* pidxViewCol);
  114. // sets column width by heading
  115. HRESULT SetColumnCacheInfo(
  116. IN int iIndex,
  117. IN int idxViewCol);
  118. public:
  119. // IPersistStream interface members
  120. HRESULT Load(IStream *pStm);
  121. HRESULT Save(IStream *pStm, BOOL fClearDirty);
  122. HRESULT GetSizeMax(int *pcbSize);
  123. };
  124. class CFolder
  125. {
  126. SCOPE_TYPES m_itemType; // Used for debug purposes. This should be the first
  127. // member. The class should not have any virtual fuctions.
  128. friend class CSnapin;
  129. friend class CComponentDataImpl;
  130. public:
  131. CFolder()
  132. {
  133. m_itemType = UNINITIALIZED_ITEM;
  134. m_cookie = UNINITIALIZED; // invalid memory address -- good cookie initializer
  135. m_enumed = FALSE;
  136. m_type = NONE;
  137. m_pszName = NULL;
  138. m_pCertCA = NULL;
  139. ZeroMemory(&m_ScopeItem, sizeof(SCOPEDATAITEM));
  140. }
  141. ~CFolder()
  142. {
  143. if (m_pszName)
  144. CoTaskMemFree(m_pszName);
  145. }
  146. // Interface
  147. public:
  148. BOOL IsEnumerated() { return m_enumed; }
  149. void Set(BOOL state) { m_enumed = state; }
  150. void SetCookie(MMC_COOKIE cookie) { m_cookie = cookie; }
  151. void SetScopeItemInformation(int nImage, int nOpenImage);
  152. FOLDER_TYPES GetType() { ASSERT(m_type != NONE); return m_type; }
  153. CertSvrCA* GetCA() { ASSERT(m_pCertCA != NULL); return m_pCertCA; }
  154. BOOL operator == (const CFolder& rhs) const { return rhs.m_cookie == m_cookie; }
  155. BOOL operator == (MMC_COOKIE cookie) const { return cookie == m_cookie; }
  156. LPCWSTR GetName() { return m_pszName; }
  157. void SetName(LPWSTR pszIn)
  158. {
  159. UINT len = wcslen(pszIn) + 1;
  160. LPWSTR psz = (LPWSTR)CoTaskMemAlloc(len * sizeof(WCHAR));
  161. if (psz != NULL)
  162. {
  163. wcscpy(psz, pszIn);
  164. CoTaskMemFree(m_pszName);
  165. m_pszName = psz;
  166. }
  167. }
  168. // IPersistStream interface members
  169. HRESULT Load(IStream *pStm);
  170. HRESULT Save(IStream *pStm, BOOL fClearDirty);
  171. HRESULT GetSizeMax(int *pcbSize);
  172. // Implementation
  173. private:
  174. void SetProperties(
  175. LPCWSTR szName,
  176. SCOPE_TYPES itemType,
  177. FOLDER_TYPES type,
  178. int iChildren = 0);
  179. // Attributes
  180. private:
  181. SCOPEDATAITEM m_ScopeItem;
  182. MMC_COOKIE m_cookie;
  183. BOOL m_enumed;
  184. FOLDER_TYPES m_type;
  185. LPOLESTR m_pszName;
  186. CertSvrCA* m_pCertCA;
  187. };
  188. BOOL IsAllowedStartStop(CFolder* pFolder, CertSvrMachine* pMachine);
  189. HRESULT GetCurrentColumnSchema(
  190. IN LPCWSTR szConfig,
  191. IN BOOL fCertView,
  192. OUT CString** pprgcstrColumns,
  193. OUT OPTIONAL LONG** pprglTypes,
  194. OUT OPTIONAL BOOL** pprgfIndexed,
  195. OUT LONG* plEntries);
  196. #endif // _FOLDERS_H_