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.

317 lines
6.7 KiB

  1. // MemberAccess.h : Declaration of the CSsrMemberAccess
  2. #pragma once
  3. #include "resource.h" // main symbols
  4. #include "global.h"
  5. using namespace std;
  6. class CSsrFilePair
  7. {
  8. public:
  9. CSsrFilePair(BSTR bstrFirst, BSTR bstrSecond, bool bIsStatic = false, bool bIsExecutable = true)
  10. : m_bstrFirst(bstrFirst),
  11. m_bstrSecond(bstrSecond),
  12. m_bIsStatic(bIsStatic),
  13. m_bIsExecutable(bIsExecutable)
  14. {}
  15. BSTR GetFirst()const
  16. {
  17. return m_bstrFirst;
  18. }
  19. BSTR GetSecond()const
  20. {
  21. return m_bstrSecond;
  22. }
  23. bool IsExecutable()const
  24. {
  25. return m_bIsExecutable;
  26. }
  27. bool IsStatic()const
  28. {
  29. return m_bIsStatic;
  30. }
  31. protected:
  32. //
  33. // we don't want anyone (include self) to be able to do an assignment
  34. // or invoking copy constructor.
  35. //
  36. CSsrFilePair (const CSsrFilePair& );
  37. void operator = (const CSsrFilePair& );
  38. private:
  39. CComBSTR m_bstrFirst;
  40. CComBSTR m_bstrSecond;
  41. bool m_bIsExecutable;
  42. bool m_bIsStatic;
  43. };
  44. class CSsrProcedure
  45. {
  46. protected:
  47. //
  48. // we don't allow direct construction. The only way to do it is
  49. // via LoadProcedure.
  50. //
  51. CSsrProcedure();
  52. public:
  53. ~CSsrProcedure();
  54. static HRESULT StaticLoadProcedure (
  55. IN IXMLDOMNode * pNode,
  56. IN bool bDefProc,
  57. IN LPCWSTR pwszProgID,
  58. OUT CSsrProcedure ** ppNewProc
  59. );
  60. bool IsDefaultProcedure()const
  61. {
  62. return m_bIsDefault;
  63. }
  64. ULONG GetFilePairCount()const
  65. {
  66. return m_vecFilePairs.size();
  67. }
  68. CSsrFilePair * GetFilePair(
  69. IN ULONG lIndex
  70. )const
  71. {
  72. if (lIndex < m_vecFilePairs.size())
  73. {
  74. return m_vecFilePairs[lIndex];
  75. }
  76. else
  77. {
  78. return NULL;
  79. }
  80. }
  81. //
  82. // Warning: don't ever release this returned BSTR!
  83. //
  84. BSTR GetProgID() const
  85. {
  86. return m_bstrProgID;
  87. }
  88. protected:
  89. //
  90. // we don't want anyone (include self) to be able to do an assignment
  91. // or invoking copy constructor.
  92. //
  93. CSsrProcedure (const CSsrProcedure& );
  94. void operator = (const CSsrProcedure& );
  95. private:
  96. bool m_bIsDefault;
  97. CComBSTR m_bstrProgID;
  98. vector<CSsrFilePair*> m_vecFilePairs;
  99. };
  100. //---------------------------------------------------------------------------
  101. // CMemberAD encapsulate member specific action data. Each CSsrMemberAccess
  102. // has an array of this class that keeps track of information for each action
  103. //---------------------------------------------------------------------------
  104. class CMemberAD
  105. {
  106. protected:
  107. //
  108. // we don't want anyone (include self) to be able to do an assignment
  109. // or invoking copy constructor.
  110. //
  111. void operator = (const CMemberAD& );
  112. CMemberAD (const CMemberAD& );
  113. //
  114. // Outsiders must load call LoadAD to create an instance
  115. // of this class.
  116. //
  117. CMemberAD (
  118. IN SsrActionVerb lActionVerb,
  119. IN LONG lActionType
  120. );
  121. public:
  122. ~CMemberAD();
  123. static HRESULT LoadAD (
  124. IN LPCWSTR pwszMemberName,
  125. IN IXMLDOMNode * pActionNode,
  126. IN LPCWSTR pwszProgID,
  127. OUT CMemberAD ** ppMAD
  128. );
  129. const BSTR GetActionName()const
  130. {
  131. return SsrPGetActionVerbString(m_AT.GetAction());
  132. }
  133. LONG GetType()const
  134. {
  135. return m_AT.GetActionType();
  136. }
  137. const CActionType * GetActionType()const
  138. {
  139. return &m_AT;
  140. }
  141. int GetProcedureCount()const
  142. {
  143. return m_vecProcedures.size();
  144. }
  145. const CSsrProcedure * GetProcedure (ULONG lIndex)
  146. {
  147. if (lIndex < m_vecProcedures.size())
  148. {
  149. return m_vecProcedures[lIndex];
  150. }
  151. else
  152. {
  153. return NULL;
  154. }
  155. }
  156. private:
  157. HRESULT LoadProcedure (
  158. IN LPCWSTR pwszMemberName,
  159. IN IXMLDOMNode * pNode,
  160. IN LPCWSTR pwszProgID
  161. );
  162. CActionType m_AT;
  163. vector<CSsrProcedure*> m_vecProcedures;
  164. };
  165. /////////////////////////////////////////////////////////////////////////////
  166. // CSsrMemberAccess
  167. class ATL_NO_VTABLE CSsrMemberAccess :
  168. public CComObjectRootEx<CComSingleThreadModel>,
  169. public IDispatchImpl<ISsrMemberAccess, &IID_ISsrMemberAccess, &LIBID_SSRLib>
  170. {
  171. protected:
  172. CSsrMemberAccess()
  173. : m_ulMajorVersion(0), m_ulMinorVersion(0)
  174. {
  175. }
  176. virtual ~CSsrMemberAccess()
  177. {
  178. Cleanup();
  179. }
  180. DECLARE_REGISTRY_RESOURCEID(IDR_SSRTENGINE)
  181. DECLARE_NOT_AGGREGATABLE(CSsrMemberAccess)
  182. DECLARE_PROTECT_FINAL_CONSTRUCT()
  183. BEGIN_COM_MAP(CSsrMemberAccess)
  184. COM_INTERFACE_ENTRY(ISsrMemberAccess)
  185. COM_INTERFACE_ENTRY(IDispatch)
  186. END_COM_MAP()
  187. // ISsrMemberAccess
  188. public:
  189. STDMETHOD(GetSupportedActions) (
  190. IN BOOL bDefault,
  191. OUT VARIANT * pvarArrayActionNames //[out, retval]
  192. );
  193. STDMETHOD(get_Name) (
  194. OUT BSTR * pbstrName // [out, retval]
  195. );
  196. STDMETHOD(get_SsrMember) (
  197. OUT VARIANT * pvarSsrMember //[out, retval]
  198. );
  199. HRESULT Load (
  200. IN LPCWSTR wszMemberFilePath
  201. );
  202. CMemberAD * GetActionDataObject (
  203. IN SsrActionVerb lActionVerb,
  204. IN LONG lActionType
  205. );
  206. HRESULT MoveOutputFiles (
  207. IN SsrActionVerb lActionVerb,
  208. IN LPCWSTR pwszDirPathSrc,
  209. IN LPCWSTR pwszDirPathDest,
  210. IN bool bIsDelete,
  211. IN bool bLog
  212. );
  213. DWORD GetActionCost (
  214. IN SsrActionVerb lActionVerb,
  215. IN LONG lActionType
  216. )const;
  217. //
  218. // ******************** Warning ********************
  219. // Caller be awared! This is an internal helper for efficient retrieval
  220. // of name. Caller must not release the returned BSTR in any form.
  221. // ******************** Warning ********************
  222. //
  223. const BSTR GetName()const
  224. {
  225. return m_bstrName;
  226. }
  227. const BSTR GetProgID()const
  228. {
  229. return m_bstrProgID;
  230. }
  231. private:
  232. void Cleanup();
  233. CComBSTR m_bstrName;
  234. CComBSTR m_bstrProgID;
  235. MapMemberAD m_mapMemAD;
  236. ULONG m_ulMajorVersion;
  237. ULONG m_ulMinorVersion;
  238. };