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.

273 lines
6.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright(C) 1997-1998 Microsoft Corporation all rights reserved.
  4. //
  5. // Module: request.h
  6. //
  7. // Project: Everest
  8. //
  9. // Description: IAS request object definition
  10. //
  11. // Author: TLP 11/11/97
  12. //
  13. // Modification history:
  14. //
  15. // 06/12/1998 sbens Added SetResponse method.
  16. // 05/21/1999 sbens Remove old style trace.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////
  19. #ifndef __IAS_REQUEST_H_
  20. #define __IAS_REQUEST_H_
  21. #include "resource.h" // main symbols
  22. #include <vector>
  23. #include <list>
  24. #include <stack>
  25. using namespace std;
  26. // Attribute position macros
  27. #define IAS_INVALID_ATTRIBUTE_POSITION 0
  28. #define IAS_RAW_CAST(x,y) *((x*)&y)
  29. ///////////
  30. // CRequest
  31. ///////////
  32. class ATL_NO_VTABLE CRequest :
  33. public CComObjectRootEx<CComMultiThreadModel>,
  34. public CComCoClass<CRequest, &CLSID_Request>,
  35. public IDispatchImpl<IRequest, &IID_IRequest, &LIBID_IASPolicyLib>
  36. {
  37. //////////////////////////////////////////////////////////////
  38. // CRequestState - Implementation of IRequestState
  39. //////////////////////////////////////////////////////////////
  40. class CRequestState : public IRequestState
  41. {
  42. // Outer unknown
  43. CRequest* m_pRequest;
  44. list<unsigned hyper> m_Stack;
  45. public:
  46. CRequestState(CRequest *pRequest);
  47. ~CRequestState();
  48. //
  49. // IUnknown methods - delegate to outer IUnknown
  50. //
  51. STDMETHOD(QueryInterface)(REFIID riid, void **ppv)
  52. { return m_pRequest->QueryInterface(riid, ppv); }
  53. STDMETHOD_(ULONG,AddRef)(void)
  54. { return m_pRequest->AddRef(); }
  55. STDMETHOD_(ULONG,Release)(void)
  56. { return m_pRequest->Release(); }
  57. //
  58. // IRequestState methods
  59. //
  60. STDMETHOD(Push)(/*[in]*/ unsigned hyper State);
  61. STDMETHOD(Pop)(/*[out]*/ unsigned hyper* pState);
  62. STDMETHOD(Top)(/*[out]*/ unsigned hyper* pState);
  63. };
  64. //////////////////////////////////////////////////////////////
  65. // CAttributesRaw - C++ view of request's attribute collection
  66. //////////////////////////////////////////////////////////////
  67. class CAttributesRaw : public IAttributesRaw
  68. {
  69. // Outer unknown
  70. CRequest* m_pRequest;
  71. public:
  72. CAttributesRaw(CRequest *pRequest);
  73. ~CAttributesRaw();
  74. //
  75. // IUnknown methods - delegate to outer IUnknown
  76. //
  77. STDMETHOD(QueryInterface)(REFIID riid, void **ppv)
  78. { return m_pRequest->QueryInterface(riid, ppv); }
  79. STDMETHOD_(ULONG,AddRef)(void)
  80. { return m_pRequest->AddRef(); }
  81. STDMETHOD_(ULONG,Release)(void)
  82. { return m_pRequest->Release(); }
  83. //
  84. // IAttributesRaw Interface
  85. //
  86. STDMETHOD(AddAttributes)(
  87. /*[in]*/ DWORD dwPosCount,
  88. /*[in, out]*/ PATTRIBUTEPOSITION pPositions
  89. );
  90. STDMETHOD(RemoveAttributes)(
  91. /*[in]*/ DWORD dwPosCount,
  92. /*[in]*/ PATTRIBUTEPOSITION pPositions
  93. );
  94. STDMETHOD(RemoveAttributesByType)(
  95. /*[in]*/ DWORD dwAttrIDCount,
  96. /*[in]*/ LPDWORD lpdwAttrIDs
  97. );
  98. STDMETHOD(GetAttributeCount)(
  99. /*[in]*/ LPDWORD lpdwCount
  100. );
  101. STDMETHOD(GetAttributes)(
  102. /*[in, out]*/ LPDWORD lpdwPosCount,
  103. /*[out]*/ PATTRIBUTEPOSITION pPositions,
  104. /*[in]*/ DWORD dwAttrIDCount,
  105. /*[in]*/ LPDWORD lpdwAttrIDs
  106. );
  107. }; // End of nested class CAttributesRaw
  108. //
  109. // Request Properties
  110. //
  111. LONG m_lRequest;
  112. LONG m_lResponse;
  113. LONG m_lReason;
  114. IASPROTOCOL m_eProtocol;
  115. IRequestSource* m_pRequestSource;
  116. //
  117. // List of COM Attribute objects
  118. //
  119. typedef list<IAttribute*> AttributeObjectList;
  120. typedef AttributeObjectList::iterator AttributeObjectListIterator;
  121. AttributeObjectList m_listAttributeObjects;
  122. //
  123. // List of raw attributes
  124. //
  125. typedef list<PIASATTRIBUTE> AttributeList;
  126. typedef AttributeList::iterator AttributeListIterator;
  127. AttributeList m_listAttributes;
  128. //
  129. // The raw attributes interface
  130. //
  131. CAttributesRaw m_clsAttributesRaw;
  132. //
  133. // The request state interface
  134. CRequestState m_clsRequestState;
  135. // Let the raw attributes nested class access the data members of CRequest
  136. friend class CAttributesRaw;
  137. friend class CRequestState;
  138. public:
  139. IAS_DECLARE_REGISTRY(Request, 1, 0, IASPolicyLib)
  140. DECLARE_NOT_AGGREGATABLE(CRequest)
  141. BEGIN_COM_MAP(CRequest)
  142. COM_INTERFACE_ENTRY(IRequest)
  143. COM_INTERFACE_ENTRY(IDispatch)
  144. COM_INTERFACE_ENTRY_FUNC(IID_IAttributesRaw, 0, &CRequest::QueryInterfaceRaw)
  145. COM_INTERFACE_ENTRY_FUNC(IID_IRequestState, 0, &CRequest::QueryInterfaceRaw)
  146. END_COM_MAP()
  147. CRequest();
  148. ~CRequest();
  149. //
  150. // IRequest Interface
  151. //
  152. ///////////////////////////////////////////////////////////////////////////
  153. // Property "get" - "set" assume that a request is always owned by the
  154. // current handler and only a single thread context within a handler
  155. // will touch it.
  156. ///////////////////////////////////////////////////////////////////////////
  157. STDMETHOD(get_Request)(/*[out, retval]*/ LONG *pVal)
  158. {
  159. _ASSERTE ( NULL != pVal );
  160. *pVal = m_lRequest;
  161. return S_OK;
  162. }
  163. STDMETHOD(put_Request)(/*[in]*/ LONG newVal)
  164. {
  165. m_lRequest = newVal;
  166. return S_OK;
  167. }
  168. STDMETHOD(get_Response)(/*[out, retval]*/ LONG *pVal)
  169. {
  170. _ASSERTE ( NULL != pVal );
  171. *pVal = m_lResponse;
  172. return S_OK;
  173. }
  174. STDMETHOD(get_Reason)(/*[out, retval]*/ LONG *pVal)
  175. {
  176. _ASSERTE ( NULL != pVal );
  177. *pVal = m_lReason;
  178. return S_OK;
  179. }
  180. STDMETHOD(get_Protocol)(/*[out, retval]*/ IASPROTOCOL *pVal)
  181. {
  182. _ASSERTE ( NULL != pVal );
  183. *pVal = m_eProtocol;
  184. return S_OK;
  185. }
  186. STDMETHOD(put_Protocol)(/*[in]*/ IASPROTOCOL newVal)
  187. {
  188. m_eProtocol = newVal;
  189. return S_OK;
  190. }
  191. STDMETHOD(get_Source)(/*[out, retval]*/ IRequestSource** ppVal)
  192. {
  193. _ASSERTE ( NULL != ppVal );
  194. if ( m_pRequestSource )
  195. {
  196. m_pRequestSource->AddRef();
  197. }
  198. *ppVal = m_pRequestSource;
  199. return S_OK;
  200. }
  201. STDMETHOD(put_Source)(/*[in]*/ IRequestSource* newVal)
  202. {
  203. _ASSERTE( NULL != newVal );
  204. if ( m_pRequestSource )
  205. {
  206. m_pRequestSource->Release();
  207. }
  208. m_pRequestSource = newVal;
  209. m_pRequestSource->AddRef();
  210. return S_OK;
  211. }
  212. STDMETHOD(get_Attributes)(/*[out, retval]*/ IDispatch** pVal);
  213. STDMETHOD(SetResponse)(
  214. /*[in]*/ IASRESPONSE eResponse,
  215. /*[in]*/ LONG lReason
  216. );
  217. STDMETHOD(ReturnToSource)(
  218. /*[in]*/ IASREQUESTSTATUS eRequestStatus
  219. );
  220. private:
  221. // Called when someone queries for any of the
  222. // request object's "Raw" interfaces.
  223. static HRESULT WINAPI QueryInterfaceRaw(
  224. void* pThis,
  225. REFIID riid,
  226. LPVOID* ppv,
  227. DWORD_PTR dw
  228. );
  229. }; // End of class CRequest
  230. #endif //__IAS_REQUEST_H_